-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #798 from tisnik/fix-issue-797
Basic tests for issue #797
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Tests for Java data normalizers.""" | ||
|
||
import pytest | ||
from f8a_worker.data_normalizer import PythonDataNormalizer | ||
|
||
|
||
@pytest.mark.parametrize('data,keymap,expected', [ | ||
# pick one key which IS there | ||
({'author': 'me', 'version': '0.1.2'}, (('author',),), {'author': 'me'}), | ||
# pick one key which IS NOT there | ||
({'author-name': 'me', 'version': '0.1.2'}, (('author',),), | ||
{'author': None}), | ||
# pick & and rename one key which IS there | ||
({'author-name': 'me'}, (('author-name', 'author',),), | ||
{'author': 'me'}), | ||
# pick & and rename one key which IS NOT there | ||
({'authors': 'they'}, (('author-name', 'author',),), | ||
{'author': None}), | ||
# pick one of keys | ||
({'license': 'MIT'}, ((('license', 'licenses',), ),), | ||
{'license': 'MIT'}), | ||
# pick one of keys | ||
({'licenses': ['MIT', 'BSD']}, ((('license', 'licenses',),),), | ||
{'licenses': ['MIT', 'BSD']}), | ||
# pick one of keys and rename it | ||
({'license': 'MIT'}, ((('license', 'licenses',), 'declared_licenses'),), | ||
{'declared_licenses': 'MIT'}), | ||
]) | ||
def test_constructor(data, keymap, expected): | ||
"""Test AbstractDataNormalizer constructor.""" | ||
dn = PythonDataNormalizer(data) | ||
assert dn is not None | ||
assert keymap | ||
assert expected | ||
|
||
|
||
def test_constructor_error_input(): | ||
"""Test AbstractDataNormalizer constructor for error input.""" | ||
dn = PythonDataNormalizer("error") | ||
assert dn is not None | ||
|
||
|
||
def test_normalize_error_input(): | ||
"""Test AbstractDataNormalizer constructor for error input.""" | ||
dn = PythonDataNormalizer("error") | ||
assert dn is not None | ||
n = dn.normalize() | ||
assert n == {} |