Tests(Firehol): Adding and improving tests for Firehol.#697
Tests(Firehol): Adding and improving tests for Firehol.#697regulartim merged 4 commits intointelowlproject:developfrom
Conversation
|
@regulartim, please check this PR out :)! |
regulartim
left a comment
There was a problem hiding this comment.
I like it! Could you also add a test case for a list containing an invalid IP address?
|
@regulartim regarding adding a test for invalid ip, from following the function call hierarchy where these requests are actually processed from firehol.py, firehol.py uses FireHolList from models.py, i was not able to find any place where invalid IPs are pre-processed/validated, and if we add tests here for invalidating ips, we might also need to do it from the root level in the FireHolList data structure in models.py which is actually responsible for invalidating ips but no exceptions are raised there basically everything is valid currently so we cannot test it. I was also not able to find any unit tests for it in test_models.py, please let me know what you think, because in my opinion is something like invalidating ip is required it would have to be implemented in a fresh pr because from my knowledge it doesnt exist currently. |
Sorry, my bad. I confused the FireHolCron with MassScannersCron, where we actually have validation. So, you don't need to add tests for this. However I do think we should implement some form of validation, maybe the same process we have in MassScannersCron. Would you like to open an issue for that? |
@regulartim Yes absolutely, i think we can wait for this to get resolved then the validation can be added on top with the tests that are required for it, i will open an issue and mention this PR as a blocker. let me know if you would like if it is done differently, like adding the validations first and then the tests can be pushed at once, or everything can be done in this pr itself. |
okay got it :) |
Description
This PR fixes and adds new test cases for test_firehol.py.
Previously .status_code was incorrectly used and we should be using .raise_for_status instead to mock the behavior of the status code. Additionally we can also test the method which cleans up old entries, and test edges like failure from certain network codes.
Related issues
Fixes #694.
Type of change
Please delete options that are not relevant.
Checklist
develop.Black,Flake,Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.Important Rules