Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for urlhaus #604

Merged
merged 36 commits into from
Jun 26, 2024
Merged

Conversation

Sekhar-Kumar-Dash
Copy link
Collaborator

@Sekhar-Kumar-Dash Sekhar-Kumar-Dash commented Jun 10, 2024

Fixes Issue #603

Changes proposed

Added more tests for urlhaus

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

@AlyaGomaa
Copy link
Collaborator

Urlhaus Unit Tests should be added to .github/workflows/CI-production-testing.yml and .github/workflows/CI-staging.yml

@Sekhar-Kumar-Dash
Copy link
Collaborator Author

Urlhaus Unit Tests should be added to .github/workflows/CI-production-testing.yml and .github/workflows/CI-staging.yml

I have already added it to production_testing.yml just forgot about CI-staging.yml Sorry i will fix it

AlyaGomaa and others added 22 commits June 14, 2024 12:57
Signed-off-by: Sebastian Garcia <eldraco@gmail.com>
Signed-off-by: Sebastian Garcia <eldraco@gmail.com>
Signed-off-by: Sebastian Garcia <eldraco@gmail.com>
…parsing_whitelist

whitelist: fix parsing commented lines
mock_response = Mock(status_code=status_code)
mock_response_instance.post.return_value = mock_response

urlhaus = URLhaus(mock_db)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be moved to module_factory, always remember no object ever used in the tests should be created in a test_*.py file, because you'll need to recreate it again later and that would cause code duplication

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check any object creation in all functions for the same issue ok?

Copy link
Collaborator Author

@Sekhar-Kumar-Dash Sekhar-Kumar-Dash Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i thought you were only asking about the object which were being used as fixture in the code
i am fixing it.

) as mock_create_session:
mock_create_session.side_effect = requests.exceptions.ConnectionError
with pytest.raises(requests.exceptions.ConnectionError):
urlhaus.make_urlhaus_request(to_lookup)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you testing here? shouldn't we be checking that the return in None in case of a Connection error? also why did you add a side effect for create_urlhaus_session() ? isnt this mock_response_instance.post.side_effect enough?

Copy link
Collaborator Author

@Sekhar-Kumar-Dash Sekhar-Kumar-Dash Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlyaGomaa I am so sorry for this is incomplete i was trying something else here.It did not go as planned then i forgot to change it

@Sekhar-Kumar-Dash
Copy link
Collaborator Author

hey @AlyaGomaa sorry for the multiple commits please only review the last three PRs

@AlyaGomaa AlyaGomaa merged commit 233cf7d into stratosphereips:develop Jun 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants