Skip to content

Conversation

lisac
Copy link
Contributor

@lisac lisac commented Apr 14, 2025

Ticket

n/a

Changes

Copies over unit tests discovered in other repositories, where the subjects of the tests are functions made available by the template flask application.

Context for reviewers

Testing

navapbc/platform-test-flask#9

lisac added 6 commits April 14, 2025 17:51
copied implementations foudn in other navapbc repos
copied implementations found in other navapbc repos
copied implementations found in other navapbc repos
copied implementations found in other navapbc repos
@lisac lisac self-assigned this Apr 14, 2025
@lisac lisac changed the title [draft] add to test coverage add to test coverage Apr 15, 2025
@lisac lisac requested review from chouinar and lorenyu April 15, 2025 17:56
@lorenyu
Copy link
Contributor

lorenyu commented Apr 15, 2025

@lisac thanks! for testing, could you make these same changes in a PR in https://github.com/navapbc/platform-test-flask so that we can make sure these changes passes CI?

@lisac
Copy link
Contributor Author

lisac commented Apr 15, 2025

hi @lorenyu ! my apologies, this is my first time working in this repo.
For testing, I created navapbc/platform-test-flask#9 and was able to get the CI job for app test to succeed (https://github.com/navapbc/platform-test-flask/actions/runs/14456152418/job/40539734786?pr=9). Is there another piece I need to account for?

Co-authored-by: Michael Chouinard <46358556+chouinar@users.noreply.github.com>
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

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

test_audit test is redundant and I don't think we should include the test_app_config test, everything else looks great, thanks!

assert_record_match(record, expected_record)


def test_get_addr_info(init_audit_hook, caplog: pytest.LogCaptureFixture):
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is redundant with test_audit_hook, there's already a use case for socket.getaddrinfo (see

pytest.param(
socket.getaddrinfo,
("www.python.org", 80),
[{"msg": "socket.getaddrinfo", "audit.args.host": "www.python.org", "audit.args.port": 80}],
id="socket.getaddrinfo",
),
)



@mock.patch.dict(os.environ, {"host": "192.123.123.123", "port": "5190"})
def test_app_config_sets_values_from_environment():
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on the fence about including this test and lean somewhat against including this test because it seems like it's kind of retesting pydantic's BaseSettings class. What sort of regression/bug is this test attempting to protect against?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

frankly, i was reacting to the test coverage % on that file. I agree with your point that it's retesting pydantic's implementation. have removed!



def test_join_list():
assert join_list(None) == ""
Copy link
Contributor

Choose a reason for hiding this comment

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

out of scope of this PR but why do we even have this function

@lisac lisac merged commit be7d6bd into main Apr 16, 2025
@lisac lisac deleted the lisac/add-test-coverage branch April 16, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants