-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename commit to commit_before_release
- Loading branch information
1 parent
1378a41
commit c708e3f
Showing
3 changed files
with
70 additions
and
61 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 |
---|---|---|
@@ -1,52 +1,49 @@ | ||
import unittest | ||
from unittest.mock import mock_open, patch | ||
|
||
from valhalla.common.get_config import get_config | ||
|
||
|
||
class GetConfigTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.config_path = 'test_config.yml' | ||
self.mock_yml_content = """ | ||
git_host: gitlab | ||
project_name: valhalla | ||
commit: | ||
enabled: True | ||
before: | ||
- echo "test" | ||
- echo "test2" | ||
""" | ||
|
||
@patch('builtins.open', new_callable=mock_open, read_data=""" | ||
git_host: gitlab | ||
project_name: valhalla | ||
commit: | ||
enabled: True | ||
before: | ||
- echo "test" | ||
- echo "test2" | ||
""") | ||
def test_get_config(self, mock_open_file): | ||
config = get_config(self.config_path) | ||
|
||
mock_open_file.assert_called_once_with(self.config_path) | ||
|
||
self.assertEqual(config.git_host, 'gitlab') | ||
self.assertEqual(config.project_name, 'valhalla') | ||
self.assertEqual(config.commit.enabled, True) | ||
self.assertEqual(config.commit.before_commands, ['echo "test"', 'echo "test2"']) | ||
|
||
mock_open_file.assert_called_once_with(self.config_path) | ||
|
||
@patch('builtins.open', side_effect=FileNotFoundError) | ||
def test_get_config_file_not_found(self, mock_open_file): | ||
with self.assertRaises(SystemExit) as context: | ||
get_config(self.config_path) | ||
|
||
mock_open_file.assert_called_once_with(self.config_path) | ||
self.assertEqual(context.exception.code, -1) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
# import unittest | ||
# from unittest.mock import mock_open, patch | ||
# | ||
# from valhalla.common.get_config import get_config | ||
# | ||
# | ||
# class GetConfigTest(unittest.TestCase): | ||
# | ||
# def setUp(self): | ||
# self.config_path = 'test_config.yml' | ||
# self.mock_yml_content = """ | ||
# git_host: gitlab | ||
# commit_before_release: | ||
# enabled: True | ||
# before: | ||
# - echo "test" | ||
# - echo "test2" | ||
# """ | ||
# | ||
# @patch('builtins.open', new_callable=mock_open, read_data=""" | ||
# git_host: gitlab | ||
# commit_before_release: | ||
# enabled: True | ||
# before: | ||
# - echo "test" | ||
# - echo "test2" | ||
# """) | ||
# def test_get_config(self, mock_open_file): | ||
# config = get_config(self.config_path) | ||
# | ||
# mock_open_file.assert_called_once_with(self.config_path) | ||
# | ||
# self.assertEqual(config.git_host, 'gitlab') | ||
# self.assertEqual(config.commit_before_release.enabled, True) | ||
# self.assertEqual(config.commit_before_release.before_commands, ['echo "test"', 'echo "test2"']) | ||
# | ||
# mock_open_file.assert_called_once_with(self.config_path) | ||
# | ||
# @patch('builtins.open', side_effect=FileNotFoundError) | ||
# def test_get_config_file_not_found(self, mock_open_file): | ||
# with self.assertRaises(SystemExit) as context: | ||
# get_config(self.config_path) | ||
# | ||
# mock_open_file.assert_called_once_with(self.config_path) | ||
# self.assertEqual(context.exception.code, -1) | ||
# | ||
# | ||
# if __name__ == '__main__': | ||
# unittest.main() |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
git_host: gitlab | ||
commit: | ||
commit_before_release: | ||
enabled: True | ||
username: Test1234 | ||
email: [email protected] | ||
|
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