Merge branch 'corp_stat_fix' into 'master'

Corp Stats update to fix removal of character name endpoints

See merge request allianceauth/allianceauth!1092
This commit is contained in:
Basraah committed 2018-07-10 02:01:26 +00:00
commit 9cc278df31
3 files changed
+8 -6

No files matched your search

+5 -3
View File
@@ -15,9 +15,11 @@ SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sw
"""
Swagger spec operations:
Character
get_characters_character_id
get_corporations_corporation_id_members
get_characters_names
Universe
post_universe_names
"""
@@ -55,11 +57,11 @@ class CorpStats(models.Model):
# the swagger spec doesn't have a maxItems count
# manual testing says we can do over 350, but let's not risk it
member_id_chunks = [member_ids[i:i + 255] for i in range(0, len(member_ids), 255)]
member_name_chunks = [c.Character.get_characters_names(character_ids=id_chunk).result() for id_chunk in
member_name_chunks = [c.Universe.post_universe_names(ids=id_chunk).result() for id_chunk in
member_id_chunks]
member_list = {}
for name_chunk in member_name_chunks:
member_list.update({m['character_id']: m['character_name'] for m in name_chunk})
member_list.update({m['id']: m['name'] for m in name_chunk})
# bulk create new member models
missing_members = [m_id for m_id in member_ids if
+1 -1
View File
@@ -1 +1 @@
{"consumes": ["application/json"], "definitions": {"bad_request": {"description": "Bad request model", "properties": {"error": {"description": "Bad request message", "type": "string"}}, "required": ["error"], "title": "Bad request", "type": "object", "x-model": "Bad request"}, "error_limited": {"description": "Error limited model", "properties": {"error": {"description": "Error limited message", "type": "string"}}, "required": ["error"], "title": "Error limited", "type": "object", "x-model": "Error limited"}, "forbidden": {"description": "Forbidden model", "properties": {"error": {"description": "Forbidden message", "type": "string"}, "sso_status": {"description": "status code received from SSO", "type": "integer"}}, "required": ["error"], "title": "Forbidden", "type": "object", "x-model": "Forbidden"}, "gateway_timeout": {"description": "Gateway timeout model", "properties": {"error": {"description": "Gateway timeout message", "type": "string"}, "timeout": {"description": "number of seconds the request was given", "type": "integer"}}, "required": ["error"], "title": "Gateway timeout", "type": "object", "x-model": "Gateway timeout"}, "internal_server_error": {"description": "Internal server error model", "properties": {"error": {"description": "Internal server error message", "type": "string"}}, "required": ["error"], "title": "Internal server error", "type": "object", "x-model": "Internal server error"}, "service_unavailable": {"description": "Service unavailable model", "properties": {"error": {"description": "Service unavailable message", "type": "string"}}, "required": ["error"], "title": "Service unavailable", "type": "object", "x-model": "Service unavailable"}, "unauthorized": {"description": "Unauthorized model", "properties": {"error": {"description": "Unauthorized message", "type": "string"}}, "required": ["error"], "title": "Unauthorized", "type": "object", "x-model": "Unauthorized"}}, "host": "esi.evetech.net", "info": {"description": "An OpenAPI for EVE Online", "title": "EVE Swagger Interface", "version": "0.8.3"}, "parameters": {"Accept-Language": {"default": "en-us", "description": "Language to use in the response", "enum": ["de", "en-us", "fr", "ja", "ru", "zh"], "in": "header", "name": "Accept-Language", "type": "string"}, "If-None-Match": {"description": "ETag from a previous request. A 304 will be returned if this matches the current ETag", "in": "header", "name": "If-None-Match", "type": "string"}, "alliance_id": {"description": "An EVE alliance ID", "format": "int32", "in": "path", "minimum": 1, "name": "alliance_id", "required": true, "type": "integer"}, "character_id": {"description": "An EVE character ID", "format": "int32", "in": "path", "minimum": 1, "name": "character_id", "required": true, "type": "integer"}, "corporation_id": {"description": "An EVE corporation ID", "format": "int32", "in": "path", "minimum": 1, "name": "corporation_id", "required": true, "type": "integer"}, "datasource": {"default": "tranquility", "description": "The server name you would like data from", "enum": ["tranquility", "singularity"], "in": "query", "name": "datasource", "type": "string"}, "language": {"default": "en-us", "description": "Language to use in the response, takes precedence over Accept-Language", "enum": ["de", "en-us", "fr", "ja", "ru", "zh"], "in": "query", "name": "language", "type": "string"}, "page": {"default": 1, "description": "Which page of results to return", "format": "int32", "in": "query", "minimum": 1, "name": "page", "type": "integer"}, "token": {"description": "Access token to use if unable to set a header", "in": "query", "name": "token", "type": "string"}}, "produces": ["application/json"], "schemes": ["https"], "securityDefinitions": {"evesso": {"authorizationUrl": "https://login.eveonline.com/oauth/authorize", "flow": "implicit", "scopes": {"esi-alliances.read_contacts.v1": "EVE SSO scope esi-alliances.read_contacts.v1", "esi-assets.read_assets.v1": "EVE SSO scope esi-assets.read_assets.v1", "esi-assets.read_corporation_assets.v1": "EVE SSO scope esi-assets.read_corporation_assets.v1", "esi-bookmarks.read_character_bookmarks.v1": "EVE SSO scope esi-bookmarks.read_character_bookmarks.v1", "esi-bookmarks.read_corporation_bookmarks.v1": "EVE SSO scope esi-bookmarks.read_corporation_bookmarks.v1", "esi-calendar.read_calendar_events.v1": "EVE SSO scope esi-calendar.read_calendar_events.v1", "esi-calendar.respond_calendar_events.v1": "EVE SSO scope esi-calendar.respond_calendar_events.v1", "esi-characters.read_agents_research.v1": "EVE SSO scope esi-characters.read_agents_research.v1", "esi-characters.read_blueprints.v1": "EVE SSO scope esi-characters.read_blueprints.v1", "esi-characters.read_contacts.v1": "EVE SSO scope esi-characters.read_contacts.v1", "esi-characters.read_corporation_roles.v1": "EVE SSO scope esi-characters.read_corporation_roles.v1", "esi-characters.read_fatigue.v1": "EVE SSO scope esi-characters.read_fatigue.v1", "esi-characters.read_fw_stats.v1": "EVELine truncated
{"consumes": ["application/json"], "definitions": {"bad_request": {"description": "Bad request model", "properties": {"error": {"description": "Bad request message", "type": "string"}}, "required": ["error"], "title": "Bad request", "type": "object", "x-model": "Bad request"}, "error_limited": {"description": "Error limited model", "properties": {"error": {"description": "Error limited message", "type": "string"}}, "required": ["error"], "title": "Error limited", "type": "object", "x-model": "Error limited"}, "forbidden": {"description": "Forbidden model", "properties": {"error": {"description": "Forbidden message", "type": "string"}, "sso_status": {"description": "status code received from SSO", "type": "integer"}}, "required": ["error"], "title": "Forbidden", "type": "object", "x-model": "Forbidden"}, "gateway_timeout": {"description": "Gateway timeout model", "properties": {"error": {"description": "Gateway timeout message", "type": "string"}, "timeout": {"description": "number of seconds the request was given", "type": "integer"}}, "required": ["error"], "title": "Gateway timeout", "type": "object", "x-model": "Gateway timeout"}, "internal_server_error": {"description": "Internal server error model", "properties": {"error": {"description": "Internal server error message", "type": "string"}}, "required": ["error"], "title": "Internal server error", "type": "object", "x-model": "Internal server error"}, "service_unavailable": {"description": "Service unavailable model", "properties": {"error": {"description": "Service unavailable message", "type": "string"}}, "required": ["error"], "title": "Service unavailable", "type": "object", "x-model": "Service unavailable"}, "unauthorized": {"description": "Unauthorized model", "properties": {"error": {"description": "Unauthorized message", "type": "string"}}, "required": ["error"], "title": "Unauthorized", "type": "object", "x-model": "Unauthorized"}}, "host": "esi.evetech.net", "info": {"description": "An OpenAPI for EVE Online", "title": "EVE Swagger Interface", "version": "0.8.3"}, "parameters": {"Accept-Language": {"default": "en-us", "description": "Language to use in the response", "enum": ["de", "en-us", "fr", "ja", "ru", "zh"], "in": "header", "name": "Accept-Language", "type": "string"}, "If-None-Match": {"description": "ETag from a previous request. A 304 will be returned if this matches the current ETag", "in": "header", "name": "If-None-Match", "type": "string"}, "alliance_id": {"description": "An EVE alliance ID", "format": "int32", "in": "path", "minimum": 1, "name": "alliance_id", "required": true, "type": "integer"}, "character_id": {"description": "An EVE character ID", "format": "int32", "in": "path", "minimum": 1, "name": "character_id", "required": true, "type": "integer"}, "corporation_id": {"description": "An EVE corporation ID", "format": "int32", "in": "path", "minimum": 1, "name": "corporation_id", "required": true, "type": "integer"}, "datasource": {"default": "tranquility", "description": "The server name you would like data from", "enum": ["tranquility", "singularity"], "in": "query", "name": "datasource", "type": "string"}, "language": {"default": "en-us", "description": "Language to use in the response, takes precedence over Accept-Language", "enum": ["de", "en-us", "fr", "ja", "ru", "zh"], "in": "query", "name": "language", "type": "string"}, "page": {"default": 1, "description": "Which page of results to return", "format": "int32", "in": "query", "minimum": 1, "name": "page", "type": "integer"}, "token": {"description": "Access token to use if unable to set a header", "in": "query", "name": "token", "type": "string"}}, "produces": ["application/json"], "schemes": ["https"], "securityDefinitions": {"evesso": {"authorizationUrl": "https://login.eveonline.com/oauth/authorize", "flow": "implicit", "scopes": {"esi-alliances.read_contacts.v1": "EVE SSO scope esi-alliances.read_contacts.v1", "esi-assets.read_assets.v1": "EVE SSO scope esi-assets.read_assets.v1", "esi-assets.read_corporation_assets.v1": "EVE SSO scope esi-assets.read_corporation_assets.v1", "esi-bookmarks.read_character_bookmarks.v1": "EVE SSO scope esi-bookmarks.read_character_bookmarks.v1", "esi-bookmarks.read_corporation_bookmarks.v1": "EVE SSO scope esi-bookmarks.read_corporation_bookmarks.v1", "esi-calendar.read_calendar_events.v1": "EVE SSO scope esi-calendar.read_calendar_events.v1", "esi-calendar.respond_calendar_events.v1": "EVE SSO scope esi-calendar.respond_calendar_events.v1", "esi-characters.read_agents_research.v1": "EVE SSO scope esi-characters.read_agents_research.v1", "esi-characters.read_blueprints.v1": "EVE SSO scope esi-characters.read_blueprints.v1", "esi-characters.read_contacts.v1": "EVE SSO scope esi-characters.read_contacts.v1", "esi-characters.read_corporation_roles.v1": "EVE SSO scope esi-characters.read_corporation_roles.v1", "esi-characters.read_fatigue.v1": "EVE SSO scope esi-characters.read_fatigue.v1", "esi-characters.read_fw_stats.v1": "EVELine truncated
+2 -2
View File
@@ -86,7 +86,7 @@ class CorpStatsUpdateTestCase(TestCase):
def test_update_add_member(self, SwaggerClient):
SwaggerClient.from_spec.return_value.Character.get_characters_character_id.return_value.result.return_value = {'corporation_id': 2}
SwaggerClient.from_spec.return_value.Corporation.get_corporations_corporation_id_members.return_value.result.return_value = [1]
SwaggerClient.from_spec.return_value.Character.get_characters_names.return_value.result.return_value = [{'character_id': 1, 'character_name': 'test character'}]
SwaggerClient.from_spec.return_value.Universe.post_universe_names.return_value.result.return_value = [{'id': 1, 'name': 'test character'}]
self.corpstats.update()
self.assertTrue(CorpMember.objects.filter(character_id='1', character_name='test character', corpstats=self.corpstats).exists())
@@ -95,7 +95,7 @@ class CorpStatsUpdateTestCase(TestCase):
CorpMember.objects.create(character_id='2', character_name='old test character', corpstats=self.corpstats)
SwaggerClient.from_spec.return_value.Character.get_characters_character_id.return_value.result.return_value = {'corporation_id': 2}
SwaggerClient.from_spec.return_value.Corporation.get_corporations_corporation_id_members.return_value.result.return_value = [1]
SwaggerClient.from_spec.return_value.Character.get_characters_names.return_value.result.return_value = [{'character_id': 1, 'character_name': 'test character'}]
SwaggerClient.from_spec.return_value.Universe.post_universe_names.return_value.result.return_value = [{'id': 1, 'name': 'test character'}]
self.corpstats.update()
self.assertFalse(CorpMember.objects.filter(character_id='2', corpstats=self.corpstats).exists())