def test_broken_url(self): # Verify that broken key url is caught with self.assertRaises(ServiceUnavailable) as context: run_ticket_validation({'ticket': self.ticket, 'appid': 123}, key_url='http://localhost:1/') self.assertIn("The server is temporarily unable", context.exception.description)
def test_steam(self): # Can't really test this. Just mock success cases from api.steampowered.com. steamid = run_ticket_validation({'steamid': self.steamid, 'ticket': self.ticket, 'appid': 123}, key_url='key url') self.assertTrue(steamid == self.steamid)
def test_missing_fields(self): # Verify missing field check. The exception will list out all missing fields, so by removing # a single field, we should only be notified of that one missing. with self.assertRaises(Unauthorized) as context: run_ticket_validation({}) self.assertIn("The token is missing required fields: ticket, appid.", context.exception.description)