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 aivpn.py #56

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

Conversation

ay-bh
Copy link

@ay-bh ay-bh commented Mar 21, 2024

Closes #55

This PR introduces unit tests for the aivpn.py. The added unit tests cover the manage_whois, validate_identity_email, validate_identity_telegram, and validate_identity_invalid functions. These tests use mocking to isolate the functionalities and ensure they behave as expected without external dependencies like a live Redis database.

Test File Details:

  • tests/test_aivpn.py: Contains the unit tests. The tests use pytest and unittest.mock for creating test cases and mocking dependencies. Logging is configured for debugging purposes, providing insights into test execution.

How to Test:
Run pytest tests/test_aivpn.py from the project root directory. (Please ensure you have redis and pytest installed through pip)

This commit introduces a suite of unit tests for the aivpn project, targeting functionalities such as `manage_whois` and identity validation. The tests employ mocking to isolate the tested components from external dependencies.
@verovaleros verovaleros linked an issue Mar 27, 2024 that may be closed by this pull request
@verovaleros
Copy link
Member

@ay-bh I'm having some issues running the tests. Maybe I'm missing something here; maybe you exported some path?

AIVPN:~$ python3 -m unittest tests/test_aivpn.py
E
======================================================================
ERROR: test_aivpn (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_aivpn
Traceback (most recent call last):
  File "/usr/lib/python3.10/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
ModuleNotFoundError: No module named 'tests.test_aivpn'


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

@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
@ay-bh
Copy link
Author

ay-bh commented Mar 27, 2024

@verovaleros I have modified my code to simplify it for some reason it was working on my computer. Please check now. To test check type pytest from the root directory. Please ensure you have redis installed from pip as aivpn.py depends on it.

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.

Implement unit tests for aivpn.py modules
2 participants