예제 #1
0
class DestinyClientTests(unittest.TestCase):

    def setUp(self):
        self.destiny_client = DestinyClient(
            api_key="4059c7cb292e46cc9fcb8b51cb09c2bd",
            membership_type="2", display_name="TRRollie", membership_id="4611686018431527730")

    def test_client_initialization(self):
        self.assertEqual("4059c7cb292e46cc9fcb8b51cb09c2bd", self.destiny_client.header['X-API-KEY'])

    def test_get_response_for_membership_id(self):
        uri = self.destiny_client.uris['membership_id']
        response = self.destiny_client.get_response(uri)
        self.assertEqual("4611686018431527730", json.load(response)['Response'])

    def test_get_response_for_membership_search(self):
        uri = self.destiny_client.uris['member_search']
        response = self.destiny_client.get_response(uri)
        self.assertEqual("4611686018431527730", json.load(response)['Response'][0]['membershipId'])

    def test_get_response_for_membership_summary(self):
        uri = self.destiny_client.uris['member_summary']
        response = self.destiny_client.get_response(uri)
        self.assertEqual(200, response.code)

    def test_get_response_for_membership_stats(self):
        uri = self.destiny_client.uris['member_stats']
        response = self.destiny_client.get_response(uri)
        self.assertEqual(200, response.code)

    def test_get_response_for_explorer_items(self):
        uri = self.destiny_client.uris['explorer_items']
        response = self.destiny_client.get_response(uri)
        self.assertEqual(200, response.code)

    def test_get_item_at_specific_hash_number(self):
        response = self.destiny_client.get_item("InventoryItem", "3164616407")
        item_name = json.load(response)['Response']['data']['inventoryItem']['itemName']
        self.assertEqual("Hawkmoon", item_name)

    def test_get_characters_for_membership_id(self):
        response = self.destiny_client.get_character_ids()
        expected = [u'2305843009229979492', u'2305843009298256265']
        self.assertEqual(response, expected)
예제 #2
0
 def setUp(self):
     self.destiny_client = DestinyClient(
         api_key="4059c7cb292e46cc9fcb8b51cb09c2bd",
         membership_type="2", display_name="TRRollie", membership_id="4611686018431527730")