AIVPN
AIVPN copied to clipboard
Add test file for AI VPN CLI: aivpn.py
Pull request type
Please check the type of change your PR introduces:
- [ ] Feature
What is the current behavior?
Closes #52
- In this unit test I created a mock Redis client object to simulate interactions with the Redis database without actually connecting to it.
- 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.
@verovaleros Kindly review this new PR please :)
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!
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.
That sounds good. I love small atomic commits with clear messages so I can track the changes as well. Thanks!
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.
Added 3 more tests
All are working fine