def test_get_image_server_link_os_variable(self, mock_os): """ Tests that the method properly uses a URL from the environment variables. """ mock_os.return_value = 'http://example.com/' image_link = eveimageserver.get_image_server_link(1234, 'type') self.assertEqual(image_link, 'http://example.com/Render/1234_128.png')
def test_get_image_server_link_os_variable(self, mock_os): """ Tests that the method properly uses a URL from the environment variables. """ mock_os.return_value = 'http://example.com/' image_link = eveimageserver.get_image_server_link(1234, 'type') self.assertEqual(image_link, 'http://example.com/Render/1234_128.png')
def test_get_image_server_link_fac_type(self, mock_os): """ Test get_image_server_link gets the correct link for fac image_type. """ mock_os.return_value = 'http://example.com/' image_link = eveimageserver.get_image_server_link(123456, 'fac', 128) self.assertEqual(image_link, 'http://example.com/Alliance/123456_128.png')
def test_get_image_server_link_fac_type(self, mock_os): """ Test get_image_server_link gets the correct link for fac image_type. """ mock_os.return_value = 'http://example.com/' image_link = eveimageserver.get_image_server_link(123456, 'fac', 128) self.assertEqual( image_link, 'http://example.com/Alliance/123456_128.png' )
def get(self, capsuleer_id): capsuleers_details = capsuleers.get_or_404(capsuleer_id) context = { 'name': capsuleers_details.name, 'security_status': capsuleers_details.security_status, 'imageserver': eveimageserver.get_image_server_link(capsuleer_id, 'char', 128), 'birthday': capsuleer_corp_history.get_birthday_from_id(capsuleer_id).start_time, } return render_template('capsuleers/details.html', context=context)
def get(self, capsuleer_id): capsuleers_details = capsuleers.get_or_404(capsuleer_id) context = { 'name': capsuleers_details.name, 'security_status': capsuleers_details.security_status, 'imageserver': eveimageserver.get_image_server_link(capsuleer_id, 'char', 128), 'birthday': capsuleer_corp_history.get_birthday_from_id( capsuleer_id).start_time, } return render_template('capsuleers/details.html', context=context)
def format_killmail_message(zkb_data): killmail = zkb_data['killmail'] if 'character' in killmail['victim']: victim_name = killmail['victim']['character']['name'] else: victim_name = killmail['victim']['shipType']['name'] victim_corp = killmail['victim']['corporation']['name'] if 'character' in killmail['attackers'][0]: killer_name = killmail['attackers'][0]['character']['name'] elif 'shipType' in killmail['attackers'][0]: killer_name = killmail['attackers'][0]['shipType']['name'] else: killer_name = 'Unknown' if 'corporation' in killmail['attackers'][0]: killer_corp = killmail['attackers'][0]['corporation']['name'] elif 'faction' in killmail['attackers'][0]: killer_corp = killmail['attackers'][0]['faction']['name'] else: killer_corp = 'Unknown' title = '{} ({}) killed {} ({})'.format(killer_name, killer_corp, victim_name, victim_corp) damage_taken = { 'title': 'Damage taken', 'value': '{:,}'.format(killmail['victim']['damageTaken']), 'short': True, } attacker_count = { 'title': 'Pilots involved', 'value': killmail['attackerCount'], 'short': True, } value = { 'title': 'Value', 'value': '{:,.2f} ISK'.format(zkb_data['zkb']['totalValue']), 'short': True, } location = { 'title': 'Location', 'value': '<https://zkillboard.com/system/{}/|{}>'.format(killmail['solarSystem']['id'], killmail['solarSystem']['name']), 'short': True, } ship = { 'title': 'Ship', 'value': killmail['victim']['shipType']['name'], 'short': True, } return { 'attachments': [ { 'title': title, 'fallback': title, 'title_link': 'https://zkillboard.com/kill/{}/'.format(zkb_data['killID']), # 'color': 'good', 'thumb_url': get_image_server_link(killmail['victim']['shipType']['id'], 'type', 64), 'fields': [ damage_taken, attacker_count, value, ship, location, ], } ] }