test_rival_regions_wrapper.py 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. """Wrapper test"""
  2. import pytest
  3. from rival_regions_wrapper.api_wrapper import Profile, Storage, Market, ResourceState
  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"
  58. @pytest.fixture
  59. def resource_keys():
  60. """Standard keys for resource"""
  61. return ['region_id', 'region_name', 'explored', 'maximum', 'deep_exploration', 'limit_left']
  62. @pytest.mark.vcr()
  63. def test_resource_state_info(resource_keys):
  64. """Test an API call to get market info"""
  65. state = 3382
  66. resource = 'oil'
  67. response = ResourceState.info(state, resource)
  68. assert isinstance(response, list), "The response should be a list"
  69. if response:
  70. assert isinstance(response[0], dict), "The first element should be a dict"
  71. assert set(resource_keys).issubset(response[0].keys()), "All keys should be in the response"
  72. assert isinstance(response[0]['region_id'], int), "The region_id should be a int"
  73. assert isinstance(response[0]['region_name'], str), "The region_name should be a str"
  74. assert isinstance(response[0]['explored'], float), "The explored should be a float"
  75. assert isinstance(response[0]['maximum'], int), "The maximum should be a int"
  76. assert isinstance(response[0]['deep_exploration'], int), "deep_exploration should be int"
  77. assert isinstance(response[0]['limit_left'], int), "The limit_left should be a int"