示例#1
0
 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')
示例#2
0
 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)
示例#3
0
 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')
示例#4
0
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")
    ]
示例#5
0
 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)
示例#6
0
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")
    ]
示例#7
0
 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')
示例#8
0
 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)
示例#9
0
 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')
示例#10
0
class ComplexModelWith2List1Normal(Model):
    fields = {'new': [], 'new2': [], 'new3': 'normal'}
    table = 'complex_inner_model'
    indices = [
        Index(["new", "new3", "new2"], "simple_new_new2_new3_index",
              "simple_id")
    ]
示例#11
0
class SimpleModelWithCreated(Model):
    fields = {'new': 'new', 'email': {'token': {'field': 'test'}}}
    table = 'complex_inner_model'
    indices = [Index(["created"], "simple_created_index", "simple_id")]
示例#12
0
 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)
示例#13
0
 def test_init(self):
     index = Index("index", "t", "e")
     self.assertEqual(index.indexOrIndices, ["index"])
     self.assertEqual(index.indexTable, "t")
     self.assertEqual(index.entityField, "e")
示例#14
0
class ComplexInnerModelWith2Lists(Model):
    fields = {'new': [], 'new2': []}
    table = 'complex_inner_model'
    indices = [Index(["new", "new2"], "simple_new_new2_index", "simple_id")]