def test_put_single_inner_dict(self): index = Index(["field1.inner"], "simple_inner_index", "simple_id") model = SimpleIndexInterface() model.data['field1'] = {'inner' : 'innerValue'} index.put(model) result = Database.get().get("SELECT field1_inner FROM simple_inner_index WHERE simple_id = %s", model._id) self.assertEqual(result['field1_inner'], 'innerValue')
def test_put_single_none(self): index = Index("field1", "simple_field1_index", "simple_id") model = SimpleIndexInterface() model.data['field1'] = None index.put(model) result = Database.get().get("SELECT field1 FROM simple_field1_index WHERE simple_id = %s", model._id) self.assertEqual(result, None)
def test_put_dobule(self): index = Index(["field1", "field2"], "simple_field_double_index", "simple_id") model = SimpleIndexInterface() index.put(model) result = Database.get().get("SELECT field1, field2 FROM simple_field_double_index WHERE simple_id = %s", model._id) self.assertEqual(result['field1'], 'field1') self.assertEqual(result['field2'], 'field2')
class ComplexInnerModelWithLists(Model): fields = {'new': [], 'new2': [], 'new3': [], 'email': {'token': []}} table = 'complex_inner_model' indices = [ Index(["new"], "simple_new_index", "simple_id"), Index(["email.token"], "simple_token_index", "simple_id") ]
def test_determine_direct_hit_2_fields(self): fql = Fql("field1 > field2") index_1 = Index(["field"], "simple_inner_index", "simple_id") index_2 = Index(["field2"], "simple_inner_index", "simple_id") index_3 = Index(["field1", "field2"], "simple_inner_index", "simple_id") index = fql.determineIndex([index_1, index_2, index_3]) self.assertEquals(index, index_3)
class ComplexInnerModel(Model): fields = {'new': 'new', 'email': {'token': 'test'}} table = 'complex_inner_model' indices = [ Index(["email.token"], "simple_token_index", "simple_id"), Index(["new"], "simple_new_index", "simple_id") ]
def test_put_single_inner_dict(self): index = Index(["field1.inner"], "simple_inner_index", "simple_id") model = SimpleIndexInterface() model.data['field1'] = {'inner': 'innerValue'} index.put(model) result = Database.get().get( "SELECT field1_inner FROM simple_inner_index WHERE simple_id = %s", model._id) self.assertEqual(result['field1_inner'], 'innerValue')
def test_put_single_none(self): index = Index("field1", "simple_field1_index", "simple_id") model = SimpleIndexInterface() model.data['field1'] = None index.put(model) result = Database.get().get( "SELECT field1 FROM simple_field1_index WHERE simple_id = %s", model._id) self.assertEqual(result, None)
def test_put_dobule(self): index = Index(["field1", "field2"], "simple_field_double_index", "simple_id") model = SimpleIndexInterface() index.put(model) result = Database.get().get( "SELECT field1, field2 FROM simple_field_double_index WHERE simple_id = %s", model._id) self.assertEqual(result['field1'], 'field1') self.assertEqual(result['field2'], 'field2')
class ComplexModelWith2List1Normal(Model): fields = {'new': [], 'new2': [], 'new3': 'normal'} table = 'complex_inner_model' indices = [ Index(["new", "new3", "new2"], "simple_new_new2_new3_index", "simple_id") ]
class SimpleModelWithCreated(Model): fields = {'new': 'new', 'email': {'token': {'field': 'test'}}} table = 'complex_inner_model' indices = [Index(["created"], "simple_created_index", "simple_id")]
def test_determine_direct_hit(self): fql = Fql("field > %s") index_1 = Index(["field"], "simple_inner_index", "simple_id") index_2 = Index(["field2"], "simple_inner_index", "simple_id") index = fql.determineIndex([index_1, index_2]) self.assertEquals(index, index_1)
def test_init(self): index = Index("index", "t", "e") self.assertEqual(index.indexOrIndices, ["index"]) self.assertEqual(index.indexTable, "t") self.assertEqual(index.entityField, "e")
class ComplexInnerModelWith2Lists(Model): fields = {'new': [], 'new2': []} table = 'complex_inner_model' indices = [Index(["new", "new2"], "simple_new_new2_index", "simple_id")]