test_rival_regions_wrapper.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """Wrapper test"""
  2. import pytest
  3. from rival_regions_wrapper.api_wrapper import Profile, Storage, Market
  4. @pytest.fixture
  5. def profile_keys():
  6. """Standard key from profile"""
  7. return ['profile_id', 'name', 'level', 'level_percentage', 'strenght', 'education', 'endurance']
  8. @pytest.mark.vcr()
  9. def test_profile_info(profile_keys):
  10. """Test an API call to get client info"""
  11. profile_instance = Profile(192852686)
  12. response = profile_instance.info()
  13. assert isinstance(response, dict), "The response should be a dict"
  14. assert response['profile_id'] == 192852686, "The ID should be in the response"
  15. assert set(profile_keys).issubset(response.keys()), "All keys should be in the response"
  16. assert isinstance(response['name'], str), "Name should be a string"
  17. assert isinstance(response['level'], int), "level should be a int"
  18. assert isinstance(response['level_percentage'], int), "level_percentage should be a int"
  19. assert isinstance(response['strenght'], int), "strenght should be a int"
  20. assert isinstance(response['education'], int), "education should be a int"
  21. assert isinstance(response['endurance'], int), "endurance should be a int"
  22. @pytest.fixture
  23. def storage_keys():
  24. """Standard keys for storage"""
  25. return [
  26. 'oil', 'ore', 'uranium', 'diamonds', 'liquid_oxygen',
  27. 'helium-3', 'rivalium', 'antirad', 'energy_drink',
  28. 'spacerockets', 'lss', 'tanks', 'aircrafts', 'missiles',
  29. 'bombers', 'battleships', 'laser_drones', 'moon_tanks', 'space_stations',
  30. 'oil_max', 'ore_max', 'uranium_max', 'diamonds_max', 'liquid_oxygen_max',
  31. 'helium-3_max', 'rivalium_max', 'antirad_max', 'energy_drink_max',
  32. 'spacerockets_max', 'lss_max', 'tanks_max', 'aircrafts_max', 'missiles_max',
  33. 'bombers_max', 'battleships_max', 'laser_drones_max', 'moon_tanks_max', 'space_stations'
  34. ]
  35. @pytest.mark.vcr()
  36. def test_storage_info(storage_keys):
  37. """Test an API call to get storage info"""
  38. response = Storage.info()
  39. assert isinstance(response, dict), "The response should be a dict"
  40. assert set(storage_keys).issubset(response.keys()), "All keys should be in the response"
  41. @pytest.fixture
  42. def market_keys():
  43. """Standard keys for storage"""
  44. return ['player_id', 'player_name', 'price', 'amount']
  45. @pytest.mark.vcr()
  46. def test_market_info(market_keys):
  47. """Test an API call to get market info"""
  48. resource = 'oil'
  49. response = Market.info(resource)
  50. assert isinstance(response, list), "The response should be a list"
  51. if response:
  52. assert isinstance(response[0], dict), "The first element should be a dict"
  53. assert set(market_keys).issubset(response[0].keys()), "All keys should be in the response"
  54. assert isinstance(response[0]['player_id'], int), "The player_id should be a int"
  55. assert isinstance(response[0]['player_name'], str), "The player_name should be a int"
  56. assert isinstance(response[0]['price'], int), "The price should be a int"
  57. assert isinstance(response[0]['amount'], int), "The price should be a int"