Beispiel #1
0
    def test_update_mutation_inputs(self):
        # create the list of inputs
        inputs = update_mutation_inputs(self.model_service)

        # the inputs of an update mutation should be the fieldsof the object
        # no required args except pk to identify the target
        # make sure the inputs match the model

        from nautilus.api.util import summarize_mutation_io
        # the dictionary of fields corresponding to the service record
        field_dict = self.model_service.model._meta.fields

        # the expected values
        expected = [summarize_mutation_io(name=key, type=_graphql_type_string(value), required=(not value.null)) \
                        for key,value in field_dict.items()]
        # make sure only the pk is required
        for field in expected:
            if field['name'] == 'id':
                field['required'] = True
            else:
                field['required'] = False

        assert inputs == expected, (
            "Update mutation inputs did not match expecttations"
        )
Beispiel #2
0
 def test_mutation_io_summary(self):
     # make sure we can summary a mutation io
     summarized = summarize_mutation_io(name="foo", type="bar")
     # make sure its a string
     assert summarized == {
         "name": "foo",
         "type": "bar",
         "required": False
     }, ("Summarized mutation io did not have the correct form.")
Beispiel #3
0
def _service_mutation_summaries(service):
    from nautilus.api.util import summarize_mutation_io, serialize_native_type
    # the dictionary of fields corresponding to the service record
    field_dict = service.model._meta.fields

    # mutation io summaries
    inputs = [summarize_mutation_io(name=key, type=serialize_native_type(value), required=(not value.null)) \
                    for key,value in field_dict.items()]

    return inputs
Beispiel #4
0
def _service_mutation_summaries(service):
    from nautilus.api.util import summarize_mutation_io, serialize_native_type
    # the dictionary of fields corresponding to the service record
    field_dict = service.model._meta.fields

    # mutation io summaries
    inputs = [summarize_mutation_io(name=key, type=serialize_native_type(value), required=(not value.null)) \
                    for key,value in field_dict.items()]

    return inputs
Beispiel #5
0
def delete_mutation_outputs(service):
    """
        Args:
            service : The service being deleted by the mutation
        Returns:
            (str): A string providing a status message
    """
    from nautilus.api.util import summarize_mutation_io

    # the only input for delete events is the pk of the service record
    return [summarize_mutation_io(name='status', type='String', required=True)]
Beispiel #6
0
def delete_mutation_inputs(service):
    """
        Args:
            service : The service being deleted by the mutation
        Returns:
            ([str]):  the only input for delete is the pk of the service.
    """
    from nautilus.api.util import summarize_mutation_io

    # the only input for delete events is the pk of the service record
    return [summarize_mutation_io(name='pk', type='ID', required=True)]
Beispiel #7
0
def delete_mutation_inputs(service):
    """
        Args:
            service : The service being deleted by the mutation
        Returns:
            ([str]):  the only input for delete is the pk of the service.
    """
    from nautilus.api.util import summarize_mutation_io

    # the only input for delete events is the pk of the service record
    return [summarize_mutation_io(name='pk', type='ID', required=True)]
Beispiel #8
0
def delete_mutation_outputs(service):
    """
        Args:
            service : The service being deleted by the mutation
        Returns:
            (str): A string providing a status message
    """
    from nautilus.api.util import summarize_mutation_io

    # the only input for delete events is the pk of the service record
    return [summarize_mutation_io(name='status', type='String', required=True)]
Beispiel #9
0
 def test_mutation_required_io_summary(self):
     # make sure we can summary a mutation io
     summarized = summarize_mutation_io(name="foo", type="bar", required=True)
     # make sure its a string
     assert summarized == {
         "name": "foo",
         "type": "bar",
         "required": True
     }, (
         "Required summarized mutation io did not have the correct form."
     )
Beispiel #10
0
    def test_delete_mutation_inputs(self):
        # the input of a delete mutation is just the pk of the model
        from nautilus.api.util import summarize_mutation_io

        # create the list of inputs
        inputs = delete_mutation_inputs(self.model_service)
        # the only input for delete events is the pk of the service record
        expected = [summarize_mutation_io(name='pk', type='ID', required=True)]

        # make sure the result matches what we expected
        assert inputs == expected, ("Delete mutation inputs were incorrect")
Beispiel #11
0
def _summarize_o_mutation_type(model):
    """
        This function create the actual mutation io summary corresponding to the model
    """
    from nautilus.api.util import summarize_mutation_io
    # compute the appropriate name for the object
    object_type_name = get_model_string(model)

    # return a mutation io object
    return summarize_mutation_io(name=object_type_name,
                                 type=_summarize_object_type(model),
                                 required=False)
Beispiel #12
0
    def test_delete_mutation_inputs(self):
        # the input of a delete mutation is just the pk of the model
        from nautilus.api.util import summarize_mutation_io

        # create the list of inputs
        inputs = delete_mutation_inputs(self.model_service)
        # the only input for delete events is the pk of the service record
        expected = [summarize_mutation_io(name='pk', type='ID', required=True)]

        # make sure the result matches what we expected
        assert inputs == expected, (
            "Delete mutation inputs were incorrect"
        )
Beispiel #13
0
def _summarize_o_mutation_type(model):
    """
        This function create the actual mutation io summary corresponding to the model
    """
    from nautilus.api.util import summarize_mutation_io
    # compute the appropriate name for the object
    object_type_name = get_model_string(model)

    # return a mutation io object
    return summarize_mutation_io(
        name=object_type_name,
        type=_summarize_object_type(model),
        required=False
    )
Beispiel #14
0
    def test_delete_mutation_outputs(self):
        # delete the list of inputs
        inputs = delete_mutation_outputs(self.model_service)

        # the output of a delete mutation is a status message indicating wether or
        # not the mutation was successful

        from nautilus.api.util import summarize_mutation_io

        # the only input for delete events is the pk of the service record
        expected = [summarize_mutation_io(name='status', type='String', required=True)]

        # make sure the result matches what we expected
        assert inputs == expected, (
            "Delete mutation outputs were incorrect"
        )
Beispiel #15
0
    def test_delete_mutation_outputs(self):
        # delete the list of inputs
        inputs = delete_mutation_outputs(self.model_service)

        # the output of a delete mutation is a status message indicating wether or
        # not the mutation was successful

        from nautilus.api.util import summarize_mutation_io

        # the only input for delete events is the pk of the service record
        expected = [
            summarize_mutation_io(name='status', type='String', required=True)
        ]

        # make sure the result matches what we expected
        assert inputs == expected, ("Delete mutation outputs were incorrect")
Beispiel #16
0
    def test_create_mutation_inputs(self):
        # create the list of inputs
        inputs = create_mutation_inputs(self.model_service)
        # make sure the inputs match the model
        from nautilus.api.util import summarize_mutation_io
        # the dictionary of fields corresponding to the service record
        field_dict = self.model_service.model._meta.fields

        # the expected values
        expected = [summarize_mutation_io(name=key, type=_graphql_type_string(value), required=(not value.null)) \
                        for key,value in field_dict.items()]

        # make sure the pk isn't required
        expected.remove([field for field in expected
                         if field['name'] == 'id'][0])

        assert inputs == expected, (
            "Create mutation inputs did not match expecttations")
Beispiel #17
0
    def test_create_mutation_inputs(self):
        # create the list of inputs
        inputs = create_mutation_inputs(self.model_service)
        # make sure the inputs match the model
        from nautilus.api.util import summarize_mutation_io
        # the dictionary of fields corresponding to the service record
        field_dict = self.model_service.model._meta.fields

        # the expected values
        expected = [summarize_mutation_io(name=key, type=_graphql_type_string(value), required=(not value.null)) \
                        for key,value in field_dict.items()]

        # make sure the pk isn't required
        expected.remove([field for field in expected if field['name'] == 'id'][0])

        assert inputs == expected, (
            "Create mutation inputs did not match expecttations"
        )
Beispiel #18
0
    def test_update_mutation_inputs(self):
        # create the list of inputs
        inputs = update_mutation_inputs(self.model_service)

        # the inputs of an update mutation should be the fieldsof the object
        # no required args except pk to identify the target
        # make sure the inputs match the model

        from nautilus.api.util import summarize_mutation_io
        # the dictionary of fields corresponding to the service record
        field_dict = self.model_service.model._meta.fields

        # the expected values
        expected = [summarize_mutation_io(name=key, type=_graphql_type_string(value), required=(not value.null)) \
                        for key,value in field_dict.items()]
        # make sure only the pk is required
        for field in expected:
            if field['name'] == 'id':
                field['required'] = True
            else:
                field['required'] = False

        assert inputs == expected, (
            "Update mutation inputs did not match expecttations")