Пример #1
0
class TestAPI(unittest.TestCase):
    """
    All network tests are here. Assumes the existence of a JSON
    file call .key.json in the local tests/ directory with the format
    {
        "steam": KEY
    }
    """
    def setUp(self):
        with open('.key.json') as f:
            key = json.load(f)['steam']
        self.h = API(key)

    @network
    def test_get_match_history(self):
        hist = self.h.get_match_history(account_id=76561198025007092,
                                        start_at_match_id=547519680,
                                        matches_requested=1)
        self.assertEqual(len(hist.matches), 1)
        self.assertEqual(hist.match_ids, [547519680])

    @network
    def test_get_match_details(self):
        MATCH_ID = 547519680
        d = self.h.get_match_details(match_id=MATCH_ID)
        self.assertEqual(d.match_id, MATCH_ID)
        self.assertEqual(d.winner, 'Radiant')

    @network
    def test_get_team_info(self):
        TEAM = 111474
        team = self.h.get_team_info(TEAM)
        self.assertEqual(team.team_id, TEAM)
Пример #2
0
def _get_test_files():
    """
    Used to generate the details_response.json file.
    """
    with open('.key.json') as f:
        key = json.load(f)['steam']
    h = API(key)

    hist = h.get_match_history(account_id=76561198025007092)
    with open('history_response.json', 'w') as f:
        json.dump(hist.resp, f)

    dr = h.get_match_details(547519680)
    with open('details_response.json', 'w') as f:
        json.dump(dr.resp, f)
Пример #3
0
 def setUp(self):
     with open('.key.json') as f:
         key = json.load(f)['steam']
     self.h = API(key)