conftest.py 967 B

12345678910111213141516171819202122232425262728293031323334353637
  1. """Test configuration"""
  2. import os
  3. import pytest
  4. from dotenv import load_dotenv
  5. from rival_regions_wrapper import LocalAuthentication, ApiWrapper
  6. load_dotenv()
  7. class MissingAuthenticationError(Exception):
  8. """Error for missing authentication"""
  9. @pytest.fixture(scope='module')
  10. def vcr(vcr):
  11. """Set parameters vor VCR"""
  12. vcr.ignore_localhost = True
  13. return vcr
  14. @pytest.fixture(scope="module")
  15. def api_wrapper():
  16. """Set up wrapper before test"""
  17. username = os.environ.get('RR_USERNAME', None)
  18. password = os.environ.get('RR_PASSWORD', None)
  19. login_method = os.environ.get('RR_LOGIN_METHOD', None)
  20. if None in (username, password, login_method):
  21. raise MissingAuthenticationError(
  22. 'Load the following variables in your user environment: '
  23. 'username, password, login_method'
  24. )
  25. authentication = LocalAuthentication(username, password, login_method)
  26. return ApiWrapper(authentication)