design test pytest
landam opened this issue · comments
Framework:
Example:
- https://gitlab.com/geoharmonizer_inea/eumap/-/blob/issue_16/tests/test_lucas.py
- https://github.com/mapradix/qcmanager/blob/master/tests/test_tc1.py
Test:
-
00a: read config: check magic values
-
00b: read mapping file, check magic values
-
00c: read template file, check magic values
-
01a -> 2a:
test_01a_read_posidents_from_file()
:
assert len(posidents) == 10
-
01b -> 2b / 2c:
test_01b_read_posidents_from_db()
: all (10), vs sql (5) -
01c -? 2d/4b:
test_01_read_posidents_from_dict()
, add nonvalid posidents (-> 12) -
02a -> 3a: test if created XML is not empty and is valid, tag exists
-
03a -> 1a : send XML, use invalid user/password, check http error code
-
03b -> 1b: modify request XML (invalid service version), send, check http error code
-
03c -> 3b/3c: send XML, check http error code, check response XML (not empty, is valid, check nonvalid posidents)
-
04a: parse response XML, check dictionary
-
04b: check number of keys == 10, check posident codes
-
05a: write output json -> check non empty, is valid, read json, check number of keys, posidents code
-
05b: write output db -> check non empty, is valid, read json, check number of keys, posidents code
TODO:
- check attribute mapping (?)
@lindakladivova Please update
Current tests for CtiOS service:
Testing pre-prepared files with service config and XML template:
- 00a: read config: check magic values ( for zeep will not be needed )
- 00b: read template file, check magic values ( for zeep will not be needed )
Testing if the service is alive:
- 01a: test if CtiOS service is working
- 01b: test the response of CtiOs service when putting invalid password
Testing reading posidents to the specified input dictionary type which is then used for XML rendering:
- 02a: read posidents from file
- 02b: read posidents from db
- 02c: read posidents from db (specified sql constraint)
- 02d: read posidents from dict
Testing manually created XML request file:
- 03a: check tags in requested XML after manual rendering ( for zeep will not be needed )
- 03b: call service when XML is invalid ( for zeep will not be needed)
Testing XML response and its parsing into dictionary:
- 03c: check response XML
- 03d: parse XML into dictionary and check results
Testing posident types after processing (checking the stats):
- 04a: check posident types after processing the request (invalid, expired etc.)
Testing the content of output files:
- 05a check writing the output to JSON
- 05b check writing the output to CSV
- 05c check mapping file used for attributes in DB and XML
- 05d check writing the output to DB
I think in terms of the logic, it should be complete - some tests are probably reduntant if we choose the way of using Zeep library.
GenerujCenoveUdaje does not have tests yet.
closed by #36 - tests for both modules