def test_save_model(self): registry = ModelRegistry() t = TestModel() conn = ElasticOSMConnection().connect(settings) registry.register_model(t) t = TestModel() assign_test_values_to_fields(t) t.save()
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)
def test_get(self): registry = ModelRegistry() t = TestModel() conn = ElasticOSMConnection().connect(settings) registry.register_model(t) t = TestModel() assign_test_values_to_fields(t) t.save() # give it a second to add to the index sleep(1) queried_model = TestModel.get(id=t.id) self.assertEqual(t.id, queried_model.id)
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)