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")
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" )
def test_can_summarize_model_mutations(self): # summarize the service summarized = self.service.summarize() # the target summary target = { 'mutations': [ { 'name': api_conventions.crud_mutation_name(action='create', model=self.model), 'event': conventions.get_crud_action(method='create', model=self.model), 'isAsync': False, 'inputs': api_conventions.create_mutation_inputs(self), 'outputs': api_conventions.create_mutation_outputs(self), }, { 'name': api_conventions.crud_mutation_name(action='update', model=self.model), 'event': conventions.get_crud_action(method='update', model=self.model), 'isAsync': False, 'inputs': api_conventions.update_mutation_inputs(self), 'outputs': api_conventions.update_mutation_outputs(self), }, { 'name': api_conventions.crud_mutation_name(action='delete', model=self.model), 'event': conventions.get_crud_action(method='delete', model=self.model), 'isAsync': False, 'inputs': api_conventions.delete_mutation_inputs(self), 'outputs': api_conventions.delete_mutation_outputs(self), }, ] } # make sure the mutations match assert len(target['mutations']) == len(summarized['mutations']), ( "Incorrect number of mutations in summary." ) # go over every mutation in the for summarized_mutation in summarized['mutations']: # grab the corresponding entry in the target equiv = [mut for mut in target['mutations'] \ if mut['name'] == summarized_mutation['name']][0] # make sure the fields match up assert equiv['event'] == summarized_mutation['event'], ( "Summarized mutation has the wrong event value" ) assert equiv['isAsync'] == summarized_mutation['isAsync'], ( "Summarized mutation has the wrong isAsync value" )