This adding a container environment to run unit test for python3.6 and python2.7 + basic unit test for all api call. Coverage for libpagure.py is now 94%
rebased onto 58aee65514c0d6a9b7db9fa3346d21aa0a5b8701
Can we move this line above the command?
Same for this. Also s/python/Python!
rebased onto 4460a551f0b7e5fba1e96b85ab2f4a464347d29d
rebased onto aaa52ba802389d2a99aec42c85fbefbbb71ab3d8
@sayanchowdhury I have made the requested changes. Do you see anything else that need to be changed ?
+1 ?
rebased onto e6cdcbc8c3e5f133d86ff6f2db294b08df54c64d
I am not sure how to run these tests. python3 setup.py test or pytest-3 tests not working for me
I added below line from pytest_mock import mocker
from pytest_mock import mocker
and now tests are executing with one error for
================================== FAILURES =================================== ____ test_create_issue ____
mocker = simple_pg =
def test_create_issue(mocker, simple_pg): """ Test the API call to create an issue """ mocker.patch('libpagure.Pagure._call_api') simple_pg.create_issue('A test issue', 'Some issue content', True) Pagure._call_api.assert_called_once_with( 'https://pagure.io/api/0/testrepo/new_issue', method='POST', data={'title': 'A test issue', 'issue_content': 'Some issue content',
'private': True}) E AssertionError: Expected call: _call_api('https://pagure.io/api/0/testrepo/new_issue', data={'title': 'A test issue', 'issue_content': 'Some issue content', 'private': True}, method='POST') E Actual call: _call_api('https://pagure.io/api/0/testrepo/new_issue', data={'title': 'A test issue', 'issue_content': 'Some issue content', 'priority': True}, method='POST') E E pytest introspection follows: E E Kwargs: E assert {'data': {'is...thod': 'POST'} == {'data': {'iss...thod': 'POST'} E Common items: E {'method': 'POST'} E Differing items: E {'data': {'issue_content': 'Some issue content', 'priority': True, 'title': 'A test issue'}} != {'data': {'issue_content': 'Some issue content', 'private': True, 'title': 'A test issue'}} E Full diff: E {'data': {'issue_content': 'Some issue content', E - 'priority': True, E ? ^^^ ^ E + 'private': True, E ? ^^ ^ E 'title': 'A test issue'}, E 'method': 'POST'}
'private': True})
E AssertionError: Expected call: _call_api('https://pagure.io/api/0/testrepo/new_issue', data={'title': 'A test issue', 'issue_content': 'Some issue content', 'private': True}, method='POST') E Actual call: _call_api('https://pagure.io/api/0/testrepo/new_issue', data={'title': 'A test issue', 'issue_content': 'Some issue content', 'priority': True}, method='POST') E E pytest introspection follows: E E Kwargs: E assert {'data': {'is...thod': 'POST'} == {'data': {'iss...thod': 'POST'} E Common items: E {'method': 'POST'} E Differing items: E {'data': {'issue_content': 'Some issue content', 'priority': True, 'title': 'A test issue'}} != {'data': {'issue_content': 'Some issue content', 'private': True, 'title': 'A test issue'}} E Full diff: E {'data': {'issue_content': 'Some issue content', E - 'priority': True, E ? ^^^ ^ E + 'private': True, E ? ^^ ^ E 'title': 'A test issue'}, E 'method': 'POST'}
tests/test_api.py:180: AssertionError ===================== 1 failed, 30 passed in 0.26 seconds =====================
That is not needed, the pytest plugin takes care of importing the fixture. Did you run the test using the docker environment ?
and now tests are executing with one error for ================================== FAILURES =================================== _ testcreate_issue __
Thanks for catching that, it is fixed now.
rebased onto 7878c7da78c4d3cdf07989b769b30fa8ac420d89
I added below line from pytest_mock import mocker That is not needed, the pytest plugin takes care of importing the fixture. Did you run the test using the docker environment ?
No but as a end user I don't know how this docker environment will help. Say I don't want to use docker and when we run test in spec file, how will they be run?
The readme is updated in this PR to describe how to run the test. If you followed this steps and it is still not working please let me know so that I can improve the readme.
rebased onto 2016e825dcf31434d75680464d4c8ee34322aa54
I have added a section to the readme on how to run the tests outside the container environment. Hope this helps
Thanks. I followed README steps and they worked fine for me. See results
platform linux -- Python 3.6.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 rootdir: /code, inifile: plugins: mock-1.6.3, cov-2.5.1 collected 31 items tests/test_api.py ............................... ----------- coverage: platform linux, python 3.6.2-final-0 ----------- Name Stmts Miss Cover --------------------------------------------- libpagure/__init__.py 1 0 100% libpagure/exceptions.py 2 0 100% libpagure/libpagure.py 226 19 92% --------------------------------------------- TOTAL 229 19 92%
Nice, then I am going to merge this PR.
Thanks for the review
Pull-Request has been merged by cverna
This adding a container environment to run unit test for python3.6 and python2.7 + basic unit test for all api call. Coverage for libpagure.py is now 94%