def test_deletes(self): registry = ModelRegistry() t = TestModel() conn = ElasticOSMConnection().connect(settings) registry.register_model(t) t = TestModel() t.string_field = 'delete me' t.save() sleep(1) t.delete() sleep(1) test_deletes_rs = TestModel.filter(string_field='delete me') self.assertEqual(test_deletes_rs.count(), 0)
def test_query(self): registry = ModelRegistry() t = TestModel() conn = ElasticOSMConnection().connect(settings) registry.register_model(t) assign_test_values_to_fields(t) t.save() # give it a second to add to the index sleep(1) queried_models = TestModel.filter(string_field=string_field_test_value) models_found = queried_models.count() self.assertGreater(models_found, 0, "Only %s TestModels returned from query, should have found at least 1" % (models_found)) for m in queried_models: self.assertEqual(m.string_field, string_field_test_value)