to solve the issue https://github.com/InternetHealthReport/internet-yellow-pages/issues/19
unit_test.py file is in the root directory, you can run it like any other Python file. "python3 unit_test.py"
The script runs all the crawlers and post scripts and sends an additional argument , "unit_test",to each one so they can start testing.
unit_test.py
It will call the config file and get all the crawlers and post scripts from the config file, loop over each one, and run them.
In the base crawler, add two methods:
count_relations: to count the number of relations that the crawler has
unit_test: count the relations of the crawler, log the number of the relations, and then run the crawler. After it finishes, count the relation again and see if the number of the relation after running is greater or not, and print if the assertion passed or failed.
and for all crawlers added: check if there is an additional arg "unit_test," and if yes, then it runs the unit test method.
for the postscripts
address_family script:
- add one method: unit_test, which runs the script, and after this, see if there is any IP or prefix that is not IPv4 or IPv6, and if yes, it failed and printed an assertion failure; else, it passed.
- in the main: add a condition to see if there is an additional arg "unit_test," and if yes, run this method.
ip2prefix.py script
- add two methods :
count_relation: to count the relation that the IP has
unit_test: count the relations before running the test and after running the test and see if the number of relations increases or not, and log and print the result.
- in the main program: add a condition to see if there is an additional arg "unit_test," and if yes, run this method.
Thanks, that's very close to be merged. Can you please make sure all the call to the crawler close method are outside of the else statement (I have commented only one but this happened several times)
to solve the issue https://github.com/InternetHealthReport/internet-yellow-pages/issues/19 unit_test.py file is in the root directory, you can run it like any other Python file. "python3 unit_test.py" The script runs all the crawlers and post scripts and sends an additional argument , "unit_test",to each one so they can start testing.
unit_test.py
In the base crawler, add two methods:
count_relations: to count the number of relations that the crawler has
unit_test: count the relations of the crawler, log the number of the relations, and then run the crawler. After it finishes, count the relation again and see if the number of the relation after running is greater or not, and print if the assertion passed or failed.
and for all crawlers added: check if there is an additional arg "unit_test," and if yes, then it runs the unit test method.
for the postscripts
address_family script:
ip2prefix.py script
- add two methods :
unit_test: count the relations before running the test and after running the test and see if the number of relations increases or not, and log and print the result.
- in the main program: add a condition to see if there is an additional arg "unit_test," and if yes, run this method.