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 test file for AI VPN CLI: aivpn.py #59

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

Conversation

Adity20
Copy link
Contributor

@Adity20 Adity20 commented Mar 27, 2024

Pull request type

Please check the type of change your PR introduces:

  • Feature

What is the current behavior?

Closes #52

  1. In this unit test I created a mock Redis client object to simulate interactions with the Redis database without actually connecting to it.
  2. Then, I called the functions to test with mock parameters and verify their behavior by adding assertions to check if the expected actions are performed.

What is the new behavior?

The project is not having any sort of unit testing right now so this is a sample unit test to start the process of "code enhancement using unit testing" project.

Other information

This unit test is related to AIVPN file.

@Adity20
Copy link
Contributor Author

Adity20 commented Mar 27, 2024

@verovaleros Kindly review this new PR please :)

@verovaleros verovaleros changed the base branch from main to develop March 27, 2024 16:25
@verovaleros
Copy link
Member

Can you write one sentence for each function test with what you aim to test? For every component of the CLI we can test for a wide variety of things, so I want to make sure we both understand exactly what functionality your tests aim to cover.

Tested locally, and all tests passed, but I want to double-check we agree on the logic. Thanks!

@verovaleros verovaleros added the enhancement New feature or request label Mar 27, 2024
@verovaleros verovaleros added this to the v0.1.3-beta milestone Mar 27, 2024
@verovaleros verovaleros changed the title adding a test file for aivpn module Add test file for AI VPN CLI: aivpn.py Mar 27, 2024
@Adity20
Copy link
Contributor Author

Adity20 commented Mar 27, 2024

I will do one thing then @verovaleros.
I will add all the tests I have written for the AIVPN CLI.
These were some of them but now I'll commit all the tests with proper comments so that it's easy to understand.

@verovaleros
Copy link
Member

That sounds good. I love small atomic commits with clear messages so I can track the changes as well. Thanks!

@Adity20
Copy link
Contributor Author

Adity20 commented Mar 27, 2024

These are some info related to each function test as you asked

test_manage_info_active_profile(self):: This is a test method for the manage_info function when the profile is active.
Inside this method, I mocked the get_profile_vpn_type function to return a specific value, simulating its behavior during testing.
Then used the patch context manager to temporarily replace the real function with the mock one during the test.

test_manage_info_expired_profile(self):: This is a test method for the manage_info function when the profile is expired.
Similar to the previous test, I mocked various functions related to expired profiles to simulate their behavior during testing.

test_manage_expire(self):: This is a test method for the manage_expire function. Inside this method, I mocked various functions related to profile expiration to simulate their behavior during testing.

@Adity20
Copy link
Contributor Author

Adity20 commented Mar 28, 2024

Added 3 more tests
All are working fine
Screenshot 2024-03-28 114726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

Successfully merging this pull request may close these issues.

Add unit test for AI VPN CLI: aivpn.py
2 participants