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

Add unit tests for coriolisclient.v1.* modules #87

Merged
merged 7 commits into from
Nov 28, 2024

Conversation

Cristi1324
Copy link
Contributor

This PR adds unit tests for coriolisclient.v1.licensing...logging modules.

@Cristi1324 Cristi1324 force-pushed the add_v1_unit_tests_2 branch from 1483fc7 to 6983cc9 Compare May 31, 2024 12:51
result = self.licence.list(mock.sentinel.appliance_id)

self.assertEqual(
mock_resource_class.return_value,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix this duplicate line bug. Because you set the expected value twice, the actual result got passed as message to assertEqual.

period,
expected_result,
raises,
has_logs
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's not an edgeg-case to log warnings in this method, we don't really care if logs are outputted. You can remove it and therefore simplify this test.

("1234567890123456789", None, True, True),
("abc", None, True, True),
("", None, True, True),
("10s", mock.ANY, False, True),
Copy link
Contributor

Choose a reason for hiding this comment

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

Put a timestamp result here please. You could achieve this by mocking datetime.datetime.utcnow, that way you have a predefined time, and can anticipate the resulting period timestamp.

mock_get
):
logs_path = os.path.dirname(os.path.realpath(__file__))
logs_path = os.path.join(logs_path, 'data')
Copy link
Contributor

Choose a reason for hiding this comment

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

Please setup a tempfile instead of pushing test results to repository :) https://docs.python.org/3/library/tempfile.html

@Cristi1324 Cristi1324 force-pushed the add_v1_unit_tests_2 branch 2 times, most recently from d281a2b to 5a7078a Compare November 26, 2024 10:33
Copy link
Contributor

@Dany9966 Dany9966 left a comment

Choose a reason for hiding this comment

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

LGTM. Will merge after the previous PR is also merged (this one has __init__.py missing in tests/v1.

@Dany9966 Dany9966 merged commit 034300d into cloudbase:master Nov 28, 2024
4 checks passed
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.

2 participants