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 more tests to test_slips_utils.py #524

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

Sekhar-Kumar-Dash
Copy link
Contributor

Fixes Issue #523

Changes proposed

This pull request adds more tests for slips_utils.py

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.

Copy link
Collaborator

@AlyaGomaa AlyaGomaa left a comment

Choose a reason for hiding this comment

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

hey @Sekhar-Kumar-Dash i will re-review your PR after using @pytest.mark.parametrize everywhere,
you can use it whenever you start calling the same function you're testing more than once in the same unit tests with different params.

you can read more about it here
https://docs.pytest.org/en/7.1.x/how-to/parametrize.html#pytest-mark-parametrize-parametrizing-test-functions

Thanks for the hard work! we appreciate it.

tests/test_slips_utils.py Outdated Show resolved Hide resolved
tests/test_slips_utils.py Outdated Show resolved Hide resolved
@Sekhar-Kumar-Dash
Copy link
Contributor Author

Sekhar-Kumar-Dash commented Apr 17, 2024

hey @Sekhar-Kumar-Dash i will re-review your PR after using @pytest.mark.parametrize everywhere, you can use it whenever you start calling the same function you're testing more than once in the same unit tests with different params.

you can read more about it here https://docs.pytest.org/en/7.1.x/how-to/parametrize.html#pytest-mark-parametrize-parametrizing-test-functions

Thanks for the hard work! we appreciate it.

Hey @AlyaGomaa , Thanks for the suggestion , I will use parametrize and update this PR soon. I will also keep this in mind for future unit test PRs. First, I thought you wanted me to use parametrize for each test you commented, but now I understand that you want me to combine similar tests into one using parametrize. Please ignore my recent changes to this PR

@Sekhar-Kumar-Dash
Copy link
Contributor Author

hey @AlyaGomaa just updated the PR please take a look

@AlyaGomaa
Copy link
Collaborator

Hello @Sekhar-Kumar-Dash the unit tests for slips_utils.py are failing

@Sekhar-Kumar-Dash
Copy link
Contributor Author

hey @AlyaGomaa I was not getting these errors locally, but I fixed it by looking into the assertion errors
please take a look

assert utils.detect_data_type(data) == expected_type


def test_get_first_octet():
Copy link
Collaborator

Choose a reason for hiding this comment

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

mark.parametrize can be used to improve this function

Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @Sekhar-Kumar-Dash this comment wasnt resolved right? you didn't use mark.parametrize in test_get_first_octet()


def test_convert_format():
utils = ModuleFactory().create_utils_obj()
assert (
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can use mark.parametrize here

Copy link
Collaborator

Choose a reason for hiding this comment

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

also this comment wasnt resolved @Sekhar-Kumar-Dash


def test_assert_microseconds():
utils = ModuleFactory().create_utils_obj()
assert utils.assert_microseconds("1680788096.789") == "1680788096.789000"
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can use mark.parametrize here

Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment wasnt resolved


def test_is_private_ip():
utils = ModuleFactory().create_utils_obj()
assert utils.is_private_ip(ipaddress.ip_address("192.168.1.1"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can mark.parametrize here. we can use it anywhere where there's repetition. you can check the rest of the file, you get the point :'D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I will use parametrize in this cases and update this PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

not resolved yet right?

),
],
)
def test_get_own_IPs(side_effect, expected_result):
Copy link
Collaborator

Choose a reason for hiding this comment

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

first thing i do when i find uppercase leters in a function name, is refactor the original function name to use lowercase, remember to use the refactor feature in your IDE instead of just renaming the function, to be able to refactor all instances of the function you're refactoring right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will look strange for this one. "IPs" is more readable than "the ips."

Copy link
Collaborator

Choose a reason for hiding this comment

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

Check this one
https://peps.python.org/pep-0008/#function-and-variable-names
we should follow this style as much as possible
get_own_ips is as readable as get_own_IPs in my opinion :'D

@Sekhar-Kumar-Dash
Copy link
Contributor Author

hey @AlyaGomaa I made the required changes please review it

Copy link
Collaborator

@AlyaGomaa AlyaGomaa left a comment

Choose a reason for hiding this comment

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

Hello @Sekhar-Kumar-Dash you marked most of my comments as resolved when you didn't do the changes, i recommend you mark them as resolved when you are done making the changes instead of when you read the changes, so you wouldn't forget the comments you read right?

Also quick reminder to pull the latest develop into your PR :))

assert utils.detect_data_type(data) == expected_type


def test_get_first_octet():
Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @Sekhar-Kumar-Dash this comment wasnt resolved right? you didn't use mark.parametrize in test_get_first_octet()


def test_convert_format():
utils = ModuleFactory().create_utils_obj()
assert (
Copy link
Collaborator

Choose a reason for hiding this comment

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

also this comment wasnt resolved @Sekhar-Kumar-Dash


def test_assert_microseconds():
utils = ModuleFactory().create_utils_obj()
assert utils.assert_microseconds("1680788096.789") == "1680788096.789000"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment wasnt resolved


def test_is_private_ip():
utils = ModuleFactory().create_utils_obj()
assert utils.is_private_ip(ipaddress.ip_address("192.168.1.1"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

not resolved yet right?

),
],
)
def test_get_own_IPs(side_effect, expected_result):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check this one
https://peps.python.org/pep-0008/#function-and-variable-names
we should follow this style as much as possible
get_own_ips is as readable as get_own_IPs in my opinion :'D

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.

None yet

2 participants