示例#1
0
 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()
示例#2
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)
示例#3
0
 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)
示例#4
0
 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)