def test_get_count_without_order_filter(self): for content in range(0, 10): SBContent(content="this is content number 2-%d" % content, to_be_deleted=True).save() queryset = NeoQuerySet(SBContent)\ .filter("WHERE res.to_be_deleted=False") self.assertEqual(queryset.count(), 50)
def test_get_count_with_order_filter_distinct_reversed(self): for content in range(0, 15): SBContent(content="this is content number 2-%d" % content, to_be_deleted=True).save() queryset = NeoQuerySet(SBContent, distinct=True, descending=True)\ .order_by('ORDER BY res.created')\ .filter("WHERE res.to_be_deleted=True") self.assertEqual(queryset.count(), 15) self.assertEqual(queryset[:1][0].content, "this is content number 2-14")
def test_get_list_with_filter(self): for content in range(0, 3): SBContent(content="this is content number 2-%d" % content, to_be_deleted=True).save() queryset = NeoQuerySet(SBContent) \ .filter("WHERE res.to_be_deleted=True")\ .order_by('ORDER BY res.created') query_res = list(queryset) self.assertEqual(queryset.count(), 3) self.assertEqual(query_res[0].content, "this is content number 2-0") self.assertEqual(query_res[1].content, "this is content number 2-1") self.assertEqual(query_res[2].content, "this is content number 2-2")
def test_get_count_without_order(self): queryset = NeoQuerySet(SBContent) self.assertEqual(queryset.count(), 50)
def test_get_count_with_order(self): queryset = NeoQuerySet(SBContent).order_by('ORDER BY res.created') self.assertEqual(queryset.count(), 50)