-
Notifications
You must be signed in to change notification settings - Fork 8
Add support for passing multiple args from handler's keyword method #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Empty file.
17 changes: 17 additions & 0 deletions
17
tests/resources/my_dummy_handlers/dummy_handler_default_params.py
This file contains hidden or 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,17 @@ | ||
| from oxygen import BaseHandler | ||
|
|
||
|
|
||
| class MyDummyHandler(BaseHandler): | ||
| ''' | ||
| A test handler that throws mismatch argument exception if single argument | ||
| is passed with multiple accepted | ||
| ''' | ||
|
|
||
| def run_my_dummy_handler(self, result_file): | ||
| return result_file | ||
|
|
||
| def parse_results(self, result_file, foo='foo'): | ||
| return { | ||
| 'name': result_file, | ||
| 'foo': foo | ||
| } |
17 changes: 17 additions & 0 deletions
17
tests/resources/my_dummy_handlers/dummy_handler_multiple_args.py
This file contains hidden or 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,17 @@ | ||
| from oxygen import BaseHandler | ||
|
|
||
|
|
||
| class MyDummyHandler(BaseHandler): | ||
| ''' | ||
| A test handler for unfolding parse_results arguments | ||
| if it has multiple parameters | ||
| ''' | ||
|
|
||
| def run_my_dummy_handler(self, result_file): | ||
| return result_file, 'foo' | ||
|
|
||
| def parse_results(self, result_file, foo): | ||
| return { | ||
| 'name': result_file, | ||
| 'foo': foo | ||
| } |
18 changes: 18 additions & 0 deletions
18
tests/resources/my_dummy_handlers/dummy_handler_multiple_args_too_few.py
This file contains hidden or 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,18 @@ | ||
| from oxygen import BaseHandler | ||
|
|
||
|
|
||
| class MyDummyHandler(BaseHandler): | ||
| ''' | ||
| A test handler that throws mismatch argument exception because | ||
| parse_results expects too many arguments | ||
| ''' | ||
|
|
||
| def run_my_dummy_handler(self, result_file): | ||
| return result_file, 'foo' | ||
|
|
||
| def parse_results(self, result_file, foo, bar): | ||
| return { | ||
| 'name': result_file, | ||
| 'foo': foo, | ||
| 'bar': bar | ||
| } |
15 changes: 15 additions & 0 deletions
15
tests/resources/my_dummy_handlers/dummy_handler_single_arg.py
This file contains hidden or 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,15 @@ | ||
| from oxygen import BaseHandler | ||
|
|
||
|
|
||
| class MyDummyHandler(BaseHandler): | ||
| ''' | ||
| A test handler for passing tuple if parse_results accepts one parameter | ||
| ''' | ||
|
|
||
| def run_my_dummy_handler(self, result_file): | ||
| return result_file, 'foo' | ||
|
|
||
| def parse_results(self, result_file): | ||
| return { | ||
| 'name': result_file | ||
| } |
This file contains hidden or 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
Empty file.
150 changes: 150 additions & 0 deletions
150
tests/utest/my_dummy_handler/test_basic_functionality.py
This file contains hidden or 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,150 @@ | ||
| import sys | ||
| from unittest import TestCase | ||
| from oxygen.errors import MismatchArgumentException | ||
| from ..helpers import RESOURCES_PATH, get_config, example_robot_output | ||
|
|
||
| sys.path.append(str(RESOURCES_PATH / 'my_dummy_handlers')) | ||
|
|
||
| from dummy_handler_single_arg import ( | ||
| MyDummyHandler as DummyHandlerSingleArg, | ||
| ) | ||
| from dummy_handler_multiple_args import ( | ||
| MyDummyHandler as DummyHandlerMultipleArgs, | ||
| ) | ||
| from dummy_handler_multiple_args_too_few import ( | ||
| MyDummyHandler as DummyHandlerMultipleArgsTooFew, | ||
| ) | ||
| from dummy_handler_default_params import ( | ||
| MyDummyHandler as DummyHandlerDefaultParams, | ||
| ) | ||
|
|
||
|
|
||
| class DummyHandlerSingleArgTests(TestCase): | ||
| ''' | ||
| A test for passing tuple if parse_results accepts one parameter | ||
| ''' | ||
|
|
||
| def setUp(self): | ||
| self.handler = DummyHandlerSingleArg( | ||
| get_config()['oxygen.my_dummy_handler'] | ||
| ) | ||
|
|
||
| def test_run_my_dummy_handler(self): | ||
| return_value = self.handler.run_my_dummy_handler('/some/path/to.ext') | ||
| self.assertTupleEqual(return_value, ('/some/path/to.ext', 'foo')) | ||
|
|
||
| def test_parse_results(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = {'Atest.Test.My Fifth Test': '/some/path/to.ext'} | ||
|
|
||
| self.handler.check_for_keyword(fake_test, expected_data) | ||
|
|
||
| self.assertEqual(self.handler.run_time_data, '/some/path/to.ext') | ||
|
|
||
|
|
||
| class DummyHandlerMultipleArgsTests(TestCase): | ||
| ''' | ||
| A test for unfolding parse_results arguments | ||
| if it has multiple parameters | ||
| ''' | ||
|
|
||
| def setUp(self): | ||
| self.handler = DummyHandlerMultipleArgs( | ||
| get_config()['oxygen.my_dummy_handler'] | ||
| ) | ||
|
|
||
| def test_parse_results(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = { | ||
| 'Atest.Test.My Fifth Test': ('/some/path/to.ext', 'foo') | ||
| } | ||
|
|
||
| self.handler.check_for_keyword(fake_test, expected_data) | ||
|
|
||
| self.assertEqual( | ||
| self.handler.run_time_data, ('/some/path/to.ext', 'foo') | ||
| ) | ||
|
|
||
|
|
||
| class DummyHandlerMultipleArgsTooFewTests(TestCase): | ||
| ''' | ||
| A test for testing if it throws mismatch argument exception because | ||
| parse_results expects too many arguments | ||
| ''' | ||
|
|
||
| def setUp(self): | ||
| self.handler = DummyHandlerMultipleArgsTooFew( | ||
| get_config()['oxygen.my_dummy_handler'] | ||
| ) | ||
|
|
||
| def test_parse_results(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = { | ||
| 'Atest.Test.My Fifth Test': ('/some/path/to.ext', 'foo') | ||
| } | ||
|
|
||
| self.assertRaises( | ||
| MismatchArgumentException, | ||
| self.handler.check_for_keyword, | ||
| fake_test, | ||
| expected_data, | ||
| ) | ||
|
|
||
|
|
||
| class DummyHandlerMultipleArgsSingleTests(TestCase): | ||
| ''' | ||
| A test for testing if it throws mismatch argument exception because | ||
| parse_results expects multiple arguments but we do not pass multiple | ||
| ''' | ||
|
|
||
| def setUp(self): | ||
| self.handler = DummyHandlerMultipleArgsTooFew( | ||
| get_config()['oxygen.my_dummy_handler'] | ||
| ) | ||
|
|
||
| def test_parse_results(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = {'Atest.Test.My Fifth Test': 'some/path/to.ext'} | ||
|
|
||
| self.assertRaises( | ||
| MismatchArgumentException, | ||
| self.handler.check_for_keyword, | ||
| fake_test, | ||
| expected_data, | ||
| ) | ||
|
|
||
|
|
||
| class DummyHandlerDefaultParamsTests(TestCase): | ||
| ''' | ||
| A test for testing arguments with defaults | ||
| ''' | ||
|
|
||
| def setUp(self): | ||
| self.handler = DummyHandlerDefaultParams( | ||
| get_config()['oxygen.my_dummy_handler'] | ||
| ) | ||
|
|
||
| def test_parse_results_with_one(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = {'Atest.Test.My Fifth Test': 'some/path/to.ext'} | ||
| self.handler.check_for_keyword(fake_test, expected_data) | ||
| self.assertEqual(self.handler.run_time_data, 'some/path/to.ext') | ||
|
|
||
| def test_parse_results_with_multiple(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = { | ||
| 'Atest.Test.My Fifth Test': ('some/path/to.ext', 'foo')} | ||
| self.handler.check_for_keyword(fake_test, expected_data) | ||
| self.assertTupleEqual( | ||
| self.handler.run_time_data, ('some/path/to.ext', 'foo')) | ||
|
|
||
| def test_parse_results_with_too_many(self): | ||
| fake_test = example_robot_output().suite.suites[0].tests[6] | ||
| expected_data = { | ||
| 'Atest.Test.My Fifth Test': ('some/path/to.ext', 'foo', 'bar')} | ||
| self.assertRaises( | ||
| MismatchArgumentException, | ||
| self.handler.check_for_keyword, | ||
| fake_test, | ||
| expected_data, | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.