Example #1
0
 def test_format_output_on_json_request(self):
     request = self.request_generator.generate_request(
         command="error_string_output_type_json")
     response = wait_for_response(self.easy_client, request)
     assert_errored_request(response)
     assert json.loads(response.output) == {
         "message": "This is a string",
         "arguments": ["This is a string"],
         "attributes": {}
     }
Example #2
0
 def test_echo_required_any_multi_message(self):
     request = self.request_generator.generate_request(
         command="echo_required_any_multi_message",
         parameters={"messages": [{
             "foo": "bar"
         }]},
     )
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert [{"foo": "bar"}] == json.loads(response.output)
Example #3
0
 def test_echo_optional_multi_nullable_model_with_model_defaults(self):
     request = self.request_generator.generate_request(
         command="echo_optional_multi_nullable_model_with_model_defaults",
         parameters={"param": [{}]})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert [{
         'my_foo': 'defaultFooFromModel',
         'my_bar': 'defaultBarFromModel'
     }] == json.loads(response.output)
Example #4
0
 def test_echo_model_with_nested_defaults_no_main_nothing_provided(self):
     request = self.request_generator.generate_request(
         command="echo_model_with_nested_defaults_no_main")
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response,
                               output=json.dumps({
                                   "my_foo":
                                   "defaultFooFromModel",
                                   "my_bar":
                                   "defaultBarFromModel"
                               }))
Example #5
0
 def test_parent_with_error_and_raise(self):
     request = self.request_generator.generate_request(
         command="say_error_and_raise", parameters={"message": "foo"})
     response = wait_for_response(self.easy_client, request)
     assert_errored_request(response)
     assert len(response.children) == 2
     for child_request in response.children:
         if child_request.system == "echo":
             assert_successful_request(child_request)
         elif child_request.system == "error":
             assert_errored_request(child_request)
Example #6
0
 def test_parent_with_children_success(self):
     request = self.request_generator.generate_request(command="say_sleep",
                                                       parameters={
                                                           "message": "foo",
                                                           "amount": 0.01
                                                       })
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert len(response.children) == 2
     for child_request in response.children:
         assert_successful_request(child_request)
Example #7
0
 def test_echo_model_simple_list_with_default(self):
     request = self.request_generator.generate_request(
         command="echo_model_simple_list_with_default")
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert json.loads(response.output) == [{
         "my_nested_string": "str1",
         "my_nested_int": 1
     }, {
         "my_nested_string": "str2",
         "my_nested_int": 2
     }]
Example #8
0
 def test_echo_model(self):
     parameters = {
         'model': {
             'my_string':
             'my_string',
             'my_string_with_choices':
             'A',
             'my_int':
             1,
             'my_float':
             1.2,
             'my_bool':
             True,
             'my_any': ["this", "is", "an", "any"],
             'my_raw_dict': {
                 "foo": "bar",
                 "baz": [1, 2, 3],
                 "null_thing": None,
                 "dict": {
                     "another": "dict"
                 },
                 "ball": 1,
                 "float": 1.2,
                 "bool": False
             },
             'my_nested_model': {
                 'my_nested_string': "my_nested_string",
                 'my_nested_int': 2
             },
             'my_list_of_strings': ['a', 'b', 'c'],
             'my_optional_string':
             'provided_anyway',
             'my_nullable_string':
             None,
             'my_list_of_models': [
                 {
                     'my_list_of_strings':
                     ['more', 'list', 'of', 'strings'],
                     "my_choices_string": "a"
                 },
                 {
                     'my_list_of_strings':
                     ['more', 'list', 'of', 'strings2'],
                     "my_choices_string": "b"
                 },
             ]
         }
     }
     request = self.request_generator.generate_request(
         command="echo_model", parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters['model'] == json.loads(response.output)
Example #9
0
 def test_echo_list_model(self):
     parameters = {
         "model": {
             "my_list_of_strings": ["a", "b", "c"],
             "my_choices_string": "a"
         }
     }
     request = self.request_generator.generate_request(
         command="echo_list_model", parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters['model'] == json.loads(response.output)
Example #10
0
 def test_echo_optional_multi_nullable_model_with_partial_default_provided(
         self):
     parameters = {'param': [{"my_foo": "foo_from_client"}]}
     request = self.request_generator.generate_request(
         command="echo_optional_multi_nullable_model_with_both_defaults",
         parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert [{
         'my_foo': 'foo_from_client',
         'my_bar': 'defaultBarFromModel'
     }] == json.loads(response.output)
Example #11
0
 def test_echo_model(self):
     parameters = {
         "model": {
             "my_string":
             "my_string",
             "my_string_with_choices":
             "A",
             "my_int":
             1,
             "my_float":
             1.2,
             "my_bool":
             True,
             "my_any": ["this", "is", "an", "any"],
             "my_raw_dict": {
                 "foo": "bar",
                 "baz": [1, 2, 3],
                 "null_thing": None,
                 "dict": {
                     "another": "dict"
                 },
                 "ball": 1,
                 "float": 1.2,
                 "bool": False,
             },
             "my_nested_model": {
                 "my_nested_string": "my_nested_string",
                 "my_nested_int": 2,
             },
             "my_list_of_strings": ["a", "b", "c"],
             "my_optional_string":
             "provided_anyway",
             "my_nullable_string":
             None,
             "my_list_of_models": [
                 {
                     "my_list_of_strings":
                     ["more", "list", "of", "strings"],
                     "my_choices_string": "a",
                 },
                 {
                     "my_list_of_strings":
                     ["more", "list", "of", "strings2"],
                     "my_choices_string": "b",
                 },
             ],
         }
     }
     request = self.request_generator.generate_request(
         command="echo_model", parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters["model"] == json.loads(response.output)
Example #12
0
 def test_echo_optional_model_with_defaults_empty_model(self):
     request = self.request_generator.generate_request(
         command="echo_optional_model_with_defaults",
         parameters={"model": {}})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response,
                               output=json.dumps({
                                   "my_foo":
                                   "defaultFooFromModel",
                                   "my_bar":
                                   "defaultBarFromModel"
                               }))
Example #13
0
 def test_echo_optional_any_multi_message_with_default(self):
     parameters = {
         "messages":
         ["foo", None, {
             "foo": "bar"
         }, 1, 1.2, ["a", "b", "c"], True]
     }
     request = self.request_generator.generate_request(
         command="echo_optional_any_multi_message_with_default",
         parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert json.loads(response.output) == parameters['messages']
Example #14
0
 def test_echo_model_with_nested_defaults_partial_fallback_to_model(self):
     model = {"my_foo": "foo"}
     request = self.request_generator.generate_request(
         command="echo_model_with_nested_defaults",
         parameters={"model": model})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response,
                               output=json.dumps({
                                   "my_foo":
                                   "foo",
                                   "my_bar":
                                   "defaultBarFromModel"
                               }))
Example #15
0
 def test_echo_optional_multi_nullable_model_list_provided(self):
     parameters = {
         'param': [{
             "my_nested_string": "str1",
             "my_nested_int": 1
         }]
     }
     request = self.request_generator.generate_request(
         command="echo_optional_multi_nullable_model",
         parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters['param'] == json.loads(response.output)
Example #16
0
 def test_weird_parameters(self):
     parameters = {
         "system": "system_value",
         "command": "command_value",
         "comment": "comment_value",
         "system_version": "system_version_value",
         "instance_name": "instance_name_value",
         "parameters": ["parameters_value"]
     }
     request = self.request_generator.generate_request(
         command="weird_parameter_names", parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters == json.loads(response.output)
Example #17
0
 def test_echo_simple_model(self):
     request = self.request_generator.generate_request(
         command="echo_simple_model",
         parameters={
             "model": {
                 "my_nested_string": "str1",
                 "my_nested_int": 1
             }
         })
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert {
         "my_nested_string": "str1",
         "my_nested_int": 1
     } == json.loads(response.output)
Example #18
0
 def test_echo_model_simple_list(self):
     parameters = {
         'models': [{
             'my_nested_string': "foo",
             "my_nested_int": 1
         }, {
             'my_nested_string': "bar",
             "my_nested_int": 2
         }, {
             'my_nested_string': "baz",
             "my_nested_int": 3
         }]
     }
     request = self.request_generator.generate_request(
         command="echo_model_simple_list", parameters=parameters)
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response)
     assert parameters['models'] == json.loads(response.output)
    def test_verify_requests(self):
        sleep(0.5)  # TODO: it is ridiculous that this is necessary
        orig_requests_len = len(self.easy_client.find_requests())

        new_request_clients = [self.easy_client, self.child_easy_client]

        for client in new_request_clients:
            new_request = wait_for_response(
                client,
                self.request_generator.generate_request(parameters={
                    "message": "test_string",
                    "loud": True
                }),
            )
            assert new_request.status == "SUCCESS"

        new_requests_len = len(self.easy_client.find_requests())

        assert new_requests_len == orig_requests_len + len(new_request_clients)
Example #20
0
 def test_say_no_parameters_provided(self):
     request = self.request_generator.generate_request()
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="Hello, World!")
Example #21
0
 def test_say_custom_string_unicode(self):
     request = self.request_generator.generate_request(
         parameters={"message": u"\U0001F4A9"})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output=u"\U0001F4A9")
Example #22
0
 def test_echo_float_valid(self):
     request = self.request_generator.generate_request(
         command="echo_float", parameters={"f": 1.2})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="1.2")
Example #23
0
 def test_optional_boolean_with_false_default(self):
     request = self.request_generator.generate_request(
         command="echo_boolean_optional_with_false_default")
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="false")
Example #24
0
 def test_nullable_boolean_with_true_not_in_param(self):
     request = self.request_generator.generate_request(
         command="echo_boolean_nullable_with_true_default", parameters={})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="true")
Example #25
0
 def test_echo_required_message_regex_valid(self):
     request = self.request_generator.generate_request(
         command="echo_required_message_regex",
         parameters={"message": "Hi."})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="Hi.")
Example #26
0
 def test_echo_required_message_nullable_true_with_default_no_key(self):
     request = self.request_generator.generate_request(
         command="echo_required_message_nullable_true_with_non_null_default",
         parameters={})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="can be null")
Example #27
0
 def test_echo_required_message_nullable_true(self):
     request = self.request_generator.generate_request(
         command="echo_required_message_nullable_true",
         parameters={"message": None})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="null")
Example #28
0
 def test_nullable_boolean_as_null(self):
     request = self.request_generator.generate_request(
         command="echo_boolean_nullable", parameters={"b": None})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="null")
Example #29
0
 def test_echo_raw_dictionary_optional_with_default(self):
     request = self.request_generator.generate_request(
         command="echo_raw_dictionary_optional_with_default", parameters={})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output=json.dumps({"foo": "bar"}))
Example #30
0
 def test_echo_raw_dictionary_nullable_optional_no_key(self):
     request = self.request_generator.generate_request(
         command="echo_raw_dictionary_optional", parameters={})
     response = wait_for_response(self.easy_client, request)
     assert_successful_request(response, output="null")