AIVPN icon indicating copy to clipboard operation
AIVPN copied to clipboard

Add unit tests for aivpn.py

Open ay-bh opened this issue 11 months ago • 2 comments

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)

ay-bh avatar Mar 21 '24 11:03 ay-bh

@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 avatar Mar 27 '24 15:03 verovaleros

@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.

ay-bh avatar Mar 27 '24 17:03 ay-bh