def assets(self): """Get information about corp assets. Each item is a dict, with keys 'id', 'item_type_id', 'quantity', 'location_id', 'location_flag', and 'packaged'. 'location_flag' denotes additional information about the item's location; see http://wiki.eve-id.net/API_Inventory_Flags for more details. If the item corresponds to a container, it will have a key 'contents', which is itself a list of items in the same format (potentially recursively holding containers of its own). If the contents do not have 'location_id's of their own, they inherit the 'location_id' of their parent container, for convenience. At the top level, the result is a dict mapping location ID (typically a solar system) to a dict containing a 'contents' key, which maps to a list of items. That is, you can think of the top-level values as "containers" with no fields except for "contents" and "location_id". """ api_result = self.api.get('char/AssetList', {'characterID': self.char_id}) return parse_assets(api_result)
def assets(self, api_result=None): """Get information about corp assets. Each item is a dict, with keys 'id', 'item_type_id', 'quantity', 'location_id', 'location_flag', and 'packaged'. 'location_flag' denotes additional information about the item's location; see http://wiki.eve-id.net/API_Inventory_Flags for more details. If the item corresponds to a container, it will have a key 'contents', which is itself a list of items in the same format (potentially recursively holding containers of its own). If the contents do not have 'location_id's of their own, they inherit the 'location_id' of their parent container, for convenience. At the top level, the result is a dict mapping location ID (typically a solar system) to a dict containing a 'contents' key, which maps to a list of items. That is, you can think of the top-level values as "containers" with no fields except for "contents" and "location_id". """ return api.APIResult(parse_assets(api_result.result), api_result.timestamp, api_result.expires)
def test_parse_assets(self): api_result, _, _ = make_api_result("corp/assets.xml") result = evelink_a.parse_assets(api_result) self.assertEqual(result, { 30003719: { 'contents': [ {'contents': [ {'id': 1007353294812, 'item_type_id': 34, 'location_flag': 42, 'location_id': 30003719, 'packaged': True, 'quantity': 100}, {'id': 1007353294813, 'item_type_id': 34, 'location_flag': 42, 'location_id': 30003719, 'packaged': True, 'quantity': 200}], 'id': 1007222140712, 'item_type_id': 16216, 'location_flag': 0, 'location_id': 30003719, 'packaged': False, 'quantity': 1, 'raw_quantity': -1}], 'location_id': 30003719}, 67000050: { 'contents': [ {'id': 1007221285456, 'item_type_id': 13780, 'location_flag': 0, 'location_id': 67000050, 'packaged': False, 'quantity': 1, 'raw_quantity': -1}, {'id': 374680079, 'item_type_id': 973, 'location_flag': 0, 'location_id': 67000050, 'packaged': False, 'quantity': 1, 'raw_quantity': -2}], 'location_id': 67000050}})
def test_parse_assets(self): api_result, _, _ = make_api_result("corp/assets.xml") result = evelink_a.parse_assets(api_result) self.assertEqual( result, { 30003719: { 'contents': [{ 'contents': [{ 'id': 1007353294812, 'item_type_id': 34, 'location_flag': 42, 'location_id': 30003719, 'packaged': True, 'quantity': 100 }, { 'id': 1007353294813, 'item_type_id': 34, 'location_flag': 42, 'location_id': 30003719, 'packaged': True, 'quantity': 200 }], 'id': 1007222140712, 'item_type_id': 16216, 'location_flag': 0, 'location_id': 30003719, 'packaged': False, 'quantity': 1, 'raw_quantity': -1 }], 'location_id': 30003719 }, 67000050: { 'contents': [{ 'id': 1007221285456, 'item_type_id': 13780, 'location_flag': 0, 'location_id': 67000050, 'packaged': False, 'quantity': 1, 'raw_quantity': -1 }, { 'id': 374680079, 'item_type_id': 973, 'location_flag': 0, 'location_id': 67000050, 'packaged': False, 'quantity': 1, 'raw_quantity': -2 }], 'location_id': 67000050 } })