#258 Tests for Fasid Search using Mocking
Merged by jflory7. Opened by alishapapun.
fedora-commops/ alishapapun/fedora-happiness-packets add/pytest-migrations  into  master

Download 258.patch

This PR address the following change
1. Refactors the Fasid Search Code, rewriting it into clean and maintainable code.
2. Add Tests for Fasid Search, using pytest-mock.

Hey, @jflory7 could you check the PR?

Metadata Update from @jflory7:
- Pull-request tagged with: PASSED, needs testing, new change, type - quality assurance, type - summer coding
- Request assigned

Hey @alishapapun, I should be able to review no later than Monday evening U.S. CDT. Thanks for sending this up! :thumbsup:

Hey @alishapapun, I should be able to review no later than Monday evening U.S. CDT. Thanks for sending this up! 👍

Sure @jflory7 .

This is a more elegant way of handling the FAS search. Nice work on cleaning this up. :thumbsup:

Minor typo: net => not

:thumbsup:

Is expected_response dict needed or could you compare to mock_response dict? I don't think the contents will change here. Dropping expected_response will keep the test shorter.

Same comment here. I think you can compare this to mock_response and drop expected_response since they are identical.

This is a great opportunity to use a fixture for this method. Notice how you call this method in multiple tests? Fixtures are a handy way to repeat methods like this and give more control over how often they are called. Then, you pass the method name as a parameter to other tests that need it. I suggest making this fixture with this annotation:

@pytest.fixture(scope=module)

See more info about fixtures in this blog post.

Then, in the tests that need the request, you can change them to use the fixture in this way:

def test_fasid_check_returns_email_name_and_privacy(mocker, call_fasid_check_and_get_response):
    response = call_fasid_check_and_get_response

Does this make sense? I think using fixtures here will make these tests more robust.

Metadata Update from @jflory7:
- Pull-request untagged with: new change
- Pull-request tagged with: needs changes
- Request assigned

Metadata Update from @jflory7:
- Pull-request untagged with: needs testing
- Pull-request tagged with: new change

Nice work @alishapapun! :raised_hands: You kept these tests simple and straightforward. I left some feedback above with some suggestions. Let me know if my feedback makes sense.

1 new commit added

  • Fix error & Add pytest-mock as dependency

2 new commits added

  • Test FASid search functionality using Mocking
  • Write clean and maintanable code for fasidCheck

rebased onto 81cf85c118fc182eb235d74ac8875fadb0d7ed96

Hey @jflory7, I just made the following changes in the code since our code aims to be robust, in addition to the pytest fixture I added made some other changes like adding pytest.mark.parametrize to facilitate taking parameters in a better way. Lemme know if any more changes are required. Thank you

Nice use of side_effect for this :thumbsup:

Nice work. These tests are simple and easy to read. They are also pretty fast – another advantage to reusing code with fixtures. :thumbsup:

Metadata Update from @jflory7:
- Pull-request untagged with: needs changes
- Request assigned

Changes look great! Nice work @alishapapun. Merging! :ocean:

Pull-Request has been merged by jflory7