forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Automation [Milestone 4]: Add pre commit tests in deploy, aut…
…omate hotfix branch creation (oppia#7790) * Add tests for deploy script * Make coverage 100% * Fix name * Add check for configs * Add newline * Fix name * Add tests for clean.py * Add tests for gcloud adapter * Add test for install third party * Add tests for install third party libs * Add test for pre push hook script * Add test for pre commit hook script * Add try finally * Add test for setup scripts * Add test for setup gae script * Add extra checks in deploy script * Fix linter * Add pre commit test for config updates * Make coverage 100% * Add test for last commit message * Add automation for cutting hotfix branch * Address review comments * Address review comments * Make coverage 100% * Update test * Address review comments
- Loading branch information
1 parent
f03d34c
commit 92f58b3
Showing
32 changed files
with
3,865 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ INCOMING_EMAILS_DOMAIN_NAME = '' | |
ADMIN_EMAIL_ADDRESS = '[email protected]' | ||
SYSTEM_EMAIL_ADDRESS = '[email protected]' | ||
NOREPLY_EMAIL_ADDRESS = '[email protected]' | ||
|
||
MAILGUN_API_KEY = None |
3 changes: 3 additions & 0 deletions
3
core/tests/release_sources/invalid_constants_with_wrong_bucket_name.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"DEV_MODE": true, | ||
"GCS_RESOURCE_BUCKET_NAME": "Bucket-name", | ||
"Testing": "Deploy-tests" |
3 changes: 3 additions & 0 deletions
3
core/tests/release_sources/invalid_constants_with_wrong_dev_mode.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"DEV_MODE": false, | ||
"GCS_RESOURCE_BUCKET_NAME": "None-resources", | ||
"Testing": "Deploy-tests" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"DEV_MODE": true, | ||
"GCS_RESOURCE_BUCKET_NAME": "None-resources", | ||
"ANALYTICS_ID": "", | ||
"SITE_NAME_FOR_ANALYTICS": "", | ||
"SITE_FEEDBACK_FORM_URL": "", | ||
"Testing": "Deploy-tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# coding: utf-8 | ||
# | ||
# Copyright 2019 The Oppia Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS-IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Unit tests for scripts/clean_test.py.""" | ||
|
||
from __future__ import absolute_import # pylint: disable=import-only-modules | ||
from __future__ import unicode_literals # pylint: disable=import-only-modules | ||
|
||
import os | ||
import shutil | ||
|
||
from core.tests import test_utils | ||
|
||
from . import clean | ||
|
||
|
||
class CleanTests(test_utils.GenericTestBase): | ||
"""Test the methods for clean script.""" | ||
def test_delete_directory_with_missing_dir(self): | ||
check_function_calls = { | ||
'rmtree_is_called': False | ||
} | ||
expected_check_function_calls = { | ||
'rmtree_is_called': False | ||
} | ||
def mock_rmtree(unused_path): | ||
check_function_calls['rmtree_is_called'] = True | ||
def mock_exists(unused_path): | ||
return False | ||
|
||
rmtree_swap = self.swap(shutil, 'rmtree', mock_rmtree) | ||
exists_swap = self.swap(os.path, 'exists', mock_exists) | ||
with rmtree_swap, exists_swap: | ||
clean.delete_directory_tree('dir_path') | ||
self.assertEqual(check_function_calls, expected_check_function_calls) | ||
|
||
def test_delete_directory_with_existing_dir(self): | ||
check_function_calls = { | ||
'rmtree_is_called': False | ||
} | ||
expected_check_function_calls = { | ||
'rmtree_is_called': True | ||
} | ||
def mock_rmtree(unused_path): | ||
check_function_calls['rmtree_is_called'] = True | ||
def mock_exists(unused_path): | ||
return True | ||
|
||
rmtree_swap = self.swap(shutil, 'rmtree', mock_rmtree) | ||
exists_swap = self.swap(os.path, 'exists', mock_exists) | ||
with rmtree_swap, exists_swap: | ||
clean.delete_directory_tree('dir_path') | ||
self.assertEqual(check_function_calls, expected_check_function_calls) | ||
|
||
def test_delete_file_with_missing_file(self): | ||
check_function_calls = { | ||
'remove_is_called': False | ||
} | ||
expected_check_function_calls = { | ||
'remove_is_called': False | ||
} | ||
def mock_remove(unused_path): | ||
check_function_calls['remove_is_called'] = True | ||
def mock_isfile(unused_path): | ||
return False | ||
|
||
remove_swap = self.swap(os, 'remove', mock_remove) | ||
isfile_swap = self.swap(os.path, 'isfile', mock_isfile) | ||
with remove_swap, isfile_swap: | ||
clean.delete_file('file_path') | ||
self.assertEqual(check_function_calls, expected_check_function_calls) | ||
|
||
def test_delete_file_with_existing_file(self): | ||
check_function_calls = { | ||
'remove_is_called': False | ||
} | ||
expected_check_function_calls = { | ||
'remove_is_called': True | ||
} | ||
def mock_remove(unused_path): | ||
check_function_calls['remove_is_called'] = True | ||
def mock_isfile(unused_path): | ||
return True | ||
|
||
remove_swap = self.swap(os, 'remove', mock_remove) | ||
isfile_swap = self.swap(os.path, 'isfile', mock_isfile) | ||
with remove_swap, isfile_swap: | ||
clean.delete_file('file_path') | ||
self.assertEqual(check_function_calls, expected_check_function_calls) | ||
|
||
def test_function_calls(self): | ||
check_function_calls = { | ||
'delete_directory_tree_is_called': 0, | ||
'delete_file_is_called': 0 | ||
} | ||
expected_check_function_calls = { | ||
'delete_directory_tree_is_called': 8, | ||
'delete_file_is_called': 4 | ||
} | ||
def mock_delete_dir(unused_path): | ||
check_function_calls['delete_directory_tree_is_called'] += 1 | ||
def mock_delete_file(unused_path): | ||
check_function_calls['delete_file_is_called'] += 1 | ||
def mock_listdir(unused_path): | ||
return ['tmpcompiledjs_dir'] | ||
delete_dir_swap = self.swap( | ||
clean, 'delete_directory_tree', mock_delete_dir) | ||
delete_file_swap = self.swap(clean, 'delete_file', mock_delete_file) | ||
listdir_swap = self.swap(os, 'listdir', mock_listdir) | ||
|
||
with delete_dir_swap, delete_file_swap, listdir_swap: | ||
clean.main(args=[]) | ||
self.assertEqual(check_function_calls, expected_check_function_calls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.