コード例 #1
0
 def test_validate_missing_auth(self):
     for k in self.good_queryparams.keys():
         q = self.good_queryparams.copy()
         q.pop(k, None)  # on each iteration, remove 1 param
         with self.assertRaises(ApiException) as exception_context:
             validate_game_submission(q, self.good_bodyparams)
         self.assertIn(k, exception_context.exception.message)
コード例 #2
0
 def test_validate_missing_auth(self):
     for k in self.good_headers.keys():
         if "X-Auth" not in k:
             continue
         q = self.good_headers.copy()
         q.pop(k, None)  # on each iteration, remove 1 param
         with self.assertRaises(ApiException) as exception_context:
             validate_game_submission(q, self.good_bodyparams)
             self.assertEqual(exception_context.exception.status_code, 403)
コード例 #3
0
 def test_validate_missing_auth(self):
     for k in self.good_headers.keys():
         if "X-Auth" not in k:
             continue
         q = self.good_headers.copy()
         q.pop(k, None)  # on each iteration, remove 1 param
         with self.assertRaises(ApiException) as exception_context:
             validate_game_submission(q, self.good_bodyparams)
             self.assertEqual(exception_context.exception.status_code, 403)
コード例 #4
0
    def test_validate_incorrect_auth(self):
        for k in self.good_headers.keys():
            if "X-Auth" not in k:
                continue
            q = self.good_headers.copy()
            q[k] = 'bad_tok'
            with self.assertRaises(ApiException) as exception_context:
                validate_game_submission(q, self.good_bodyparams)

            expected = 'token unknown or expired'
            self.assertIn(expected, exception_context.exception.message)
コード例 #5
0
 def test_validate_missing_params(self):
     for k in self.good_bodyparams.keys():
         q = self.good_bodyparams.copy()
         q.pop(k, None)  # on each iteration, remove 1 param
         with self.assertRaises(ApiException) as exception_context:
             validate_game_submission(self.good_headers, q)
         if k == 'game_record':
             expected = 'One of game_record or game_url must be present'
             self.assertEqual(expected, exception_context.exception.message)
         else:
             self.assertIn(k, exception_context.exception.message)
コード例 #6
0
    def test_validate_incorrect_auth(self):
        for k in self.good_headers.keys():
            if "X-Auth" not in k:
                continue
            q = self.good_headers.copy()
            q[k] = 'bad_tok'
            with self.assertRaises(ApiException) as exception_context:
                validate_game_submission(q, self.good_bodyparams)

            expected = 'token unknown or expired'
            self.assertIn(expected, exception_context.exception.message)
コード例 #7
0
 def test_validate_missing_params(self):
     for k in self.good_bodyparams.keys():
         q = self.good_bodyparams.copy()
         q.pop(k, None)  # on each iteration, remove 1 param
         with self.assertRaises(ApiException) as exception_context:
             validate_game_submission(self.good_headers, q)
         if k == 'game_record':
             expected = 'One of game_record or game_url must be present'
             self.assertEqual(expected, exception_context.exception.message)
         else:
             self.assertIn(k, exception_context.exception.message)
コード例 #8
0
    def test_validate_bad_user_token(self):
        for param in ['w_tok', 'b_tok', 'server_tok']:
            # User token is bad
            q = self.good_queryparams.copy()
            q[param] = 'bad_tok'
            with self.assertRaises(ApiException) as exception_context:
                validate_game_submission(q, self.good_bodyparams)

            if param == 'server_tok':
                expected = 'server access token unknown or expired: bad_tok'
            else:
                expected = 'user access token unknown or expired: bad_tok'
            self.assertEqual(expected, exception_context.exception.message)
コード例 #9
0
    def test_validate_rated(self):
        bodyparams = self.good_bodyparams.copy()
        for is_rated in [True, False]:
            bodyparams['rated'] = is_rated
            game = validate_game_submission(self.good_queryparams, bodyparams)
            self.assertEqual(game.rated, is_rated)

        bodyparams['rated'] = '0'
        with self.assertRaises(ApiException) as exception_context:
            validate_game_submission(self.good_queryparams, bodyparams)

        expected = 'rated must be set to True or False'
        self.assertEqual(expected, exception_context.exception.message)