示例#1
0
 def test_errors_when_missing_fields(self):
     type_ = ActionType.CHOICE
     request_with_missing_fields = {
         "action": {
             "type": "choice",
             "tile_id": 3,  # random
         },
     }
     with pytest.raises(MissingFieldException):
         parse_request(type_, request_with_missing_fields)
示例#2
0
 def test_errors_when_invalid_action_type(self):
     type_ = ActionType.BUZZ
     inconsistent_request = {
         "message_id": 4,  # random
         "action": {
             "type": "invalid_action",
             "tile_id": 4,  # random
         },
     }
     with pytest.raises(ForbiddenActionException):
         parse_request(type_, inconsistent_request)
示例#3
0
    def test_does_not_error_when_extra_fields(self):
        type_ = ActionType.BUZZ
        request_with_extra_fields = {
            "message_id": 2,  # random
            "action": {
                "type": "buzz",
                "tile_id": 6,  # random
                "extra_field": "test",
            },
            "another_extra_field": "test",
        }

        parse_request(type_, request_with_extra_fields)
示例#4
0
 def test_errors_when_input_request_does_not_match_action_type(
     self, incoming_request_response
 ):
     type_ = ActionType.BUZZ
     with pytest.raises(ForbiddenActionException):
         parse_request(type_, incoming_request_response)
示例#5
0
 def test_output_action_is_wager_type_for_wager(
     self, incoming_request_wager
 ):
     type_ = ActionType.WAGER
     request = parse_request(type_, incoming_request_wager)
     assert isinstance(request.action, Wager)
示例#6
0
 def test_output_action_is_response_type_for_response(
     self, incoming_request_response
 ):
     type_ = ActionType.RESPONSE
     request = parse_request(type_, incoming_request_response)
     assert isinstance(request.action, Response)
示例#7
0
 def test_output_action_is_action_type_for_choice(
     self, incoming_request_choice
 ):
     type_ = ActionType.CHOICE
     request = parse_request(type_, incoming_request_choice)
     assert isinstance(request.action, Action)
示例#8
0
 def test_output_action_is_action_type_for_buzz(
     self, incoming_request_buzz
 ):
     type_ = ActionType.BUZZ
     request = parse_request(type_, incoming_request_buzz)
     assert isinstance(request.action, Action)
示例#9
0
 def test_output_action_type_is_enum_instead_of_string(
     self, incoming_request
 ):
     request = parse_request(*incoming_request)
     assert isinstance(request.action.type_, ActionType)
示例#10
0
 def test_output_is_request_type(self, incoming_request):
     request = parse_request(*incoming_request)
     assert isinstance(request, Request)