-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
6 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
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
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,27 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<requirements document-relative-path="testing/requirements" project-id="CLOUDTP"> | ||
<properties> | ||
<property name="prop1" value="val1"/> | ||
<property name="prop2" value="val2"/> | ||
<property name="lookup-method" value="name"/> | ||
</properties> | ||
<requirement approver-ids="sbulage:approved" assignee-id="mkourim" category-ids="CAT-01" due-date="2018-05-30" initial-estimate="1/4h" planned-in-ids="PROJ-01" priority-id="medium" severity-id="good_to_have" status-id="STAT-01"> | ||
<title>req01</title> | ||
<custom-fields> | ||
<custom-field content="functional" id="reqtype"/> | ||
</custom-fields> | ||
</requirement> | ||
<requirement approver-ids="mkourim:approved" assignee-id="mkourim" initial-estimate="1/4h" priority-id="high" severity-id="should_have"> | ||
<title>req02</title> | ||
<description>requirement description</description> | ||
<custom-fields> | ||
<custom-field content="functional" id="reqtype"/> | ||
</custom-fields> | ||
</requirement> | ||
<requirement approver-ids="mkourim:approved" assignee-id="mkourim" priority-id="high" severity-id="should_have"> | ||
<title>req03</title> | ||
<custom-fields> | ||
<custom-field content="functional" id="reqtype"/> | ||
</custom-fields> | ||
</requirement> | ||
</requirements> |
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,83 @@ | ||
# encoding: utf-8 | ||
# pylint: disable=missing-docstring,redefined-outer-name,no-self-use,protected-access | ||
# pylint: disable=c-extension-no-member | ||
|
||
from __future__ import unicode_literals | ||
|
||
import copy | ||
import io | ||
import os | ||
|
||
import pytest | ||
from tests import conf | ||
|
||
from dump2polarion.exceptions import Dump2PolarionException, NothingToDoException | ||
from dump2polarion.requirements_exporter import RequirementExport | ||
|
||
|
||
REQ_DATA = [ | ||
{ | ||
'title': 'req01', | ||
'approver-ids': 'sbulage:approved', | ||
'assignee-id': 'mkourim', | ||
'category-ids': 'CAT-01', | ||
'due-date': '2018-05-30', | ||
'planned-in-ids': 'PROJ-01', | ||
'initial-estimate': '1/4h', | ||
'priority-id': 'medium', | ||
'severity-id': 'good_to_have', | ||
'status-id': 'STAT-01', | ||
'reqtype': 'functional', | ||
}, | ||
{ | ||
'title': 'req02', | ||
'description': 'requirement description', | ||
'assignee-id': 'mkourim', | ||
'initial-estimate': '1/4h', | ||
}, | ||
{ | ||
'id': 'PROJ-01', | ||
'title': 'req03', | ||
'initial-estimate': None, | ||
}, | ||
{ | ||
'id': 'PROJ-02', | ||
}, | ||
] | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def config_cloudtp(config_prop): | ||
config_prop['xunit_import_properties']['polarion-project-id'] = 'CLOUDTP' | ||
config_prop['requirements-document-relative-path'] = 'testing/requirements' | ||
config_prop['requirements_import_properties'] = { | ||
'prop1': 'val1', | ||
'prop2': 'val2', | ||
} | ||
return config_prop | ||
|
||
|
||
class TestRequirement(object): | ||
def test_export(self, config_cloudtp): | ||
req_exp = RequirementExport(REQ_DATA, config_cloudtp) | ||
complete = req_exp.export() | ||
fname = 'requirement_complete.xml' | ||
with io.open(os.path.join(conf.DATA_PATH, fname), encoding='utf-8') as input_xml: | ||
parsed = input_xml.read() | ||
assert complete == parsed | ||
|
||
def test_invalid_lookup(self, config_cloudtp): | ||
new_config = copy.deepcopy(config_cloudtp) | ||
new_config['requirements_import_properties'] = { | ||
'lookup-method': 'inv', | ||
} | ||
req_exp = RequirementExport(REQ_DATA, new_config) | ||
with pytest.raises(Dump2PolarionException) as excinfo: | ||
req_exp.export() | ||
assert "Invalid value 'inv' for the 'lookup-method' property" in str(excinfo.value) | ||
|
||
def test_no_requirements(self, config_cloudtp): | ||
req_exp = RequirementExport([], config_cloudtp) | ||
with pytest.raises(NothingToDoException) as excinfo: | ||
req_exp.export() | ||
assert 'Nothing to export' in str(excinfo.value) |
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