def _model_exists_step(self, model, should_exist):
model = get_model(model)<EOL>data = guess_types(self.hashes)<EOL>queryset = model.objects<EOL>try:<EOL><INDENT>existence_check = _TEST_MODEL[model]<EOL><DEDENT>except KeyError:<EOL><INDENT>existence_check = test_existence<EOL><DEDENT>failed = <NUM_LIT:0><EOL>try:<EOL><INDENT>for hash_ in data:<EOL><INDENT>match = existence_check(queryset, hash_)<EOL>if should_exist:<EOL><INDENT>assert match,"<STR_LIT>" % (model.__name__, hash_)<EOL><DEDENT>else:<EOL><INDENT>assert not match,"<STR_LIT>" % (model.__name__, hash_)<EOL><DEDENT><DEDENT><DEDENT>except AssertionError as exc:<EOL><INDENT>print(exc)<EOL>failed += <NUM_LIT:1><EOL><DEDENT>if failed:<EOL><INDENT>print("<STR_LIT>")<EOL>for existing_model in queryset.all():<EOL><INDENT>_dump_model(existing_model,<EOL>attrs=[k[<NUM_LIT:1>:]<EOL>for k in data[<NUM_LIT:0>].keys()<EOL>if k.startswith('<STR_LIT:@>')])<EOL><DEDENT>if should_exist:<EOL><INDENT>raise AssertionError("<STR_LIT>" % failed)<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError("<STR_LIT>" % failed)<EOL><DEDENT><DEDENT>
Test for the existence of a model matching the given data.