def test_war_info(api_wrapper): """Test war info""" war = War(api_wrapper) war_page = war.page() war_id = war_page['training_war'] response = war.info(war_id) assert isinstance(response, dict), "The response should be a dict" assert isinstance(response['damage'], int), \ "Damage should be an int" assert isinstance(response['attack_hourly_available'], bool), \ "Attack hourly should be a bool" assert isinstance(response['energ_drinks'], int), \ "Energy drinks should be an int" if 'max_hero_name' in response: assert isinstance(response['max_hero_name'], str), \ "max hero name should be a str" if 'max_hero_damage' in response: assert isinstance(response['max_hero_damage'], int), \ "max hero damage should be an int" if 'time_left' in response: assert isinstance(response['time_left'], timedelta), \ "time left should be a time delta" assert isinstance(response['finish_date'], datetime), \ "Finish date should be a date" assert isinstance(response['war_units'], dict), \ "war units should be a dict"
def test_war_info_space_war(api_wrapper): """Test war info""" war_id = 329531 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" assert response['type'] == 'space war', "Type should be a space war"
def test_war_info_trooper_war(api_wrapper): """Test war info""" war_id = 329458 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" assert response['type'] == 'troopers war', "Type should be a trooper war"
def test_war_info_revolution(api_wrapper): """Test war info""" war_id = 329461 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" assert response['type'] == 'revolution', "Type should be a revolution"
def test_war_info_coup(api_wrapper): """Test war info""" war_id = 329518 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" assert response['type'] == 'coup', "Type should be a coup"
def test_war_info_ground_war(api_wrapper): """Test war info""" war_id = 329541 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" assert response['type'] == 'war', "Type should be a ground war" assert isinstance(response['attack'], dict), "Attack should be a dict" assert isinstance(response['attack']['state_id'], int), \ "State id should be an integer" assert isinstance(response['attack']['state_name'], str), \ "State nameshould be a string" assert isinstance(response['attack']['region_id'], int), \ "Region id should be an integer" assert isinstance(response['attack']['region_name'], str), \ "Region name should be a string" assert isinstance(response['attack']['damage'], int), \ "Damage should be an intger" assert isinstance(response['defend']['state_id'], int), \ "State id should be an integer" assert isinstance(response['defend']['state_name'], str), \ "State name should be a string" assert isinstance(response['defend']['region_id'], int), \ "Region id should be an integer" assert isinstance(response['defend']['region_name'], str), \ "Region name should be a string" assert isinstance(response['defend']['damage'], int), \ "Damage should be an integer"
def test_war_page(): """Test getting training war""" response = War.page() assert isinstance(response, dict), "The response should be a dict" assert isinstance(response['training_war'], int), "The training_war should be an int"
def test_war_page(api_wrapper): """Test getting training war""" response = War(api_wrapper).page() assert isinstance(response, dict), "The response should be a dict" if response['training_war']: assert isinstance(response['training_war'], int), \ "The training_war should be an int"
def test_send_war_coup_message(api_wrapper, telegram_bot, telegram_channel): """Test format war""" war_id = 329518 response = War(api_wrapper).info(war_id) assert isinstance(response, dict), "The response should be a dict" formatted_war = functions.telegram_format_war(response) if telegram_channel: telegram_bot.sendMessage(telegram_channel, formatted_war, parse_mode=ParseMode.MARKDOWN_V2)
def get_war(war_id): """Get war by id""" return War(API_WRAPPER).info(war_id)