123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- """Wrapper test"""
- import pytest
- from rival_regions_wrapper.api_wrapper import Profile, Storage, Market
- @pytest.fixture
- def profile_keys():
- """Standard key from profile"""
- return ['profile_id', 'name', 'level', 'level_percentage', 'strenght', 'education', 'endurance']
- @pytest.mark.vcr()
- def test_profile_info(profile_keys):
- """Test an API call to get client info"""
- profile_instance = Profile(192852686)
- response = profile_instance.info()
- assert isinstance(response, dict), "The response should be a dict"
- assert response['profile_id'] == 192852686, "The ID should be in the response"
- assert set(profile_keys).issubset(response.keys()), "All keys should be in the response"
- assert isinstance(response['name'], str), "Name should be a string"
- assert isinstance(response['level'], int), "level should be a int"
- assert isinstance(response['level_percentage'], int), "level_percentage should be a int"
- assert isinstance(response['strenght'], int), "strenght should be a int"
- assert isinstance(response['education'], int), "education should be a int"
- assert isinstance(response['endurance'], int), "endurance should be a int"
- @pytest.fixture
- def storage_keys():
- """Standard keys for storage"""
- return [
- 'oil', 'ore', 'uranium', 'diamonds', 'liquid_oxygen',
- 'helium-3', 'rivalium', 'antirad', 'energy_drink',
- 'spacerockets', 'lss', 'tanks', 'aircrafts', 'missiles',
- 'bombers', 'battleships', 'laser_drones', 'moon_tanks', 'space_stations',
- 'oil_max', 'ore_max', 'uranium_max', 'diamonds_max', 'liquid_oxygen_max',
- 'helium-3_max', 'rivalium_max', 'antirad_max', 'energy_drink_max',
- 'spacerockets_max', 'lss_max', 'tanks_max', 'aircrafts_max', 'missiles_max',
- 'bombers_max', 'battleships_max', 'laser_drones_max', 'moon_tanks_max', 'space_stations'
- ]
- @pytest.mark.vcr()
- def test_storage_info(storage_keys):
- """Test an API call to get storage info"""
- response = Storage.info()
- assert isinstance(response, dict), "The response should be a dict"
- assert set(storage_keys).issubset(response.keys()), "All keys should be in the response"
- @pytest.fixture
- def market_keys():
- """Standard keys for storage"""
- return ['player_id', 'player_name', 'price', 'amount']
- @pytest.mark.vcr()
- def test_market_info(market_keys):
- """Test an API call to get market info"""
- resource = 'oil'
- response = Market.info(resource)
- assert isinstance(response, list), "The response should be a list"
- if response:
- assert isinstance(response[0], dict), "The first element should be a dict"
- assert set(market_keys).issubset(response[0].keys()), "All keys should be in the response"
- assert isinstance(response[0]['player_id'], int), "The player_id should be a int"
- assert isinstance(response[0]['player_name'], str), "The player_name should be a int"
- assert isinstance(response[0]['price'], int), "The price should be a int"
- assert isinstance(response[0]['amount'], int), "The price should be a int"
|