Пример #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")