def test_get_3rd_then_next_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 3
     self.map.values(predicate)
     predicate.next_page()
     self.assertEqual(self.map.values(predicate), [48, 49])
 def test_nonexistent_next_page(self):
     # Trying to get next page while already at last page should return empty list.
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 4
     predicate.next_page()
     self.assertEqual(self.map.values(predicate), [])
 def test_get_4th_then_previous_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 4
     self.map.values(predicate)
     predicate.previous_page()
     self.assertEqual(self.map.values(predicate), [46, 47])
 def test_reset(self):
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     self.assertEqual(self.map.values(predicate), [40, 41])
     predicate.next_page()
     self.assertEqual(self.map.values(predicate), [42, 43])
     predicate.reset()
     self.assertEqual(self.map.values(predicate), [40, 41])
 def test_previous_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal('this', 40), 2)
     predicate.page = 4
     predicate.previous_page()
     self.assertEqual(self.map.values(predicate), [46, 47])
 def test_set_nonexistent_page(self):
     # Trying to get page 10, which is out of range, should return empty list.
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 10
     self.assertEqual(self.map.values(predicate), [])
 def test_get_page(self):
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 4
     self.assertEqual(predicate.page, 4)
 def test_first_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     self.assertEqual(self.map.values(predicate), [40, 41])
Beispiel #9
0
 def test_multi_attribute_with_predicate(self):
     attributes = self.map.project(
         multi_attribute("attr1", "attr2"),
         greater_or_equal("attr2", 3),
     )
     self.assertCountEqual([[4, 5]], attributes)
Beispiel #10
0
 def test_single_attribute_with_predicate(self):
     attributes = self.map.project(single_attribute("attr1"),
                                   greater_or_equal("attr1", 4))
     self.assertCountEqual([4], attributes)
Beispiel #11
0
 def test_min_with_predicate(self):
     average = self.map.aggregate(min_(), greater_or_equal("this", 3))
     self.assertEqual(3, average)
Beispiel #12
0
 def test_double_sum_with_predicate(self):
     sum_ = self.map.aggregate(double_sum(), greater_or_equal("this", 47))
     self.assertEqual(144, sum_)
Beispiel #13
0
 def test_count_with_predicate(self):
     count_ = self.map.aggregate(count(), greater_or_equal("this", 1))
     self.assertEqual(49, count_)
    "LikePredicate":
    predicate.like(_sql_string, _sql_string),
    "ILikePredicate":
    predicate.ilike(_sql_string, _sql_string),
    "InPredicate":
    predicate.in_(_sql_string, REFERENCE_OBJECTS["Integer"],
                  REFERENCE_OBJECTS["Integer"]),
    "RegexPredicate":
    predicate.regex(_sql_string, _sql_string),
    "AndPredicate":
    predicate.and_(
        predicate.sql(_sql_string),
        predicate.equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.not_equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.greater(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.greater_or_equal(_sql_string, REFERENCE_OBJECTS["Integer"])),
    "OrPredicate":
    predicate.or_(
        predicate.sql(_sql_string),
        predicate.equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.not_equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.greater(_sql_string, REFERENCE_OBJECTS["Integer"]),
        predicate.greater_or_equal(_sql_string, REFERENCE_OBJECTS["Integer"])),
    "InstanceOfPredicate":
    predicate.instance_of(
        "com.hazelcast.nio.serialization.compatibility.CustomStreamSerializable"
    )
})

_SKIP_ON_SERIALIZE = {
    "Character",
 def test_key_set_with_paging_predicate(self):
     self.fill_map(3)
     key_set = self.map.key_set(paging(greater_or_equal("this", 2), 1))
     self.assertEqual(len(key_set), 1)
     self.assertEqual(key_set[0], "key-2")
 def test_values_with_paging_predicate(self):
     self.fill_map(3)
     values = self.map.values(paging(greater_or_equal("this", 2), 1))
     self.assertEqual(len(values), 1)
     self.assertEqual(values[0], 2)
Beispiel #17
0
 def test_identity_with_predicate(self):
     attributes = self.map.project(identity(), greater_or_equal("attr2", 3))
     self.assertCountEqual(
         [HazelcastJsonValue('{"attr1": 4, "attr2": 5, "attr3": 6}')],
         [attribute.value for attribute in attributes],
     )
 def test_set_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.page = 4
     self.assertEqual(self.map.values(predicate), [48, 49])
Beispiel #19
0
 def test_fixed_point_sum_with_predicate(self):
     sum_ = self.map.aggregate(fixed_point_sum(),
                               greater_or_equal("this", 47))
     self.assertEqual(144, sum_)
 def test_page_size(self):
     predicate = paging(greater_or_equal("this", 40), 2)
     self.assertEqual(predicate.page_size, 2)
Beispiel #21
0
 def test_distinct_with_predicate(self):
     self._fill_with_duplicate_values()
     distinct_values = self.map.aggregate(distinct(),
                                          greater_or_equal("this", 10))
     self.assertEqual(set(range(10, 50)), distinct_values)
Beispiel #22
0
 def test_min_by_with_predicate(self):
     min_item = self.map.aggregate(min_by("this"),
                                   greater_or_equal("this", 10))
     self.assertEqual("key-10", min_item.key)
     self.assertEqual(10, min_item.value)
Beispiel #23
0
 def test_long_average_with_predicate(self):
     average = self.map.aggregate(long_avg(), greater_or_equal("this", 47))
     self.assertEqual(48, average)
 def test_nonexistent_previous_page(self):
     # Trying to get previous page while already at first page should return first page.
     self.fill_map()
     predicate = paging(greater_or_equal("this", 40), 2)
     predicate.previous_page()
     self.assertEqual(self.map.values(predicate), [40, 41])
 def test_greater_than_or_equal(self):
     self.fill_map_numeric()
     predicate = greater_or_equal("this", 10)
     self.assertCountEqual(self.map.key_set(predicate), list(range(10,
                                                                   100)))
 def test_get_half_full_last_page(self):
     # Page size set to 2, but last page only has 1 element.
     self.fill_map()
     predicate = paging(greater_or_equal("this", 41), 2)
     predicate.page = 4
     self.assertEqual(self.map.values(predicate), [49])
 def test_entry_set_with_paging_predicate(self):
     self.fill_map(3)
     entry_set = self.map.entry_set(paging(greater_or_equal("this", 2), 1))
     self.assertEqual(len(entry_set), 1)
     self.assertEqual(entry_set[0], ("key-2", 2))
 def test_empty_map(self):
     # Empty map should return empty list.
     predicate = paging(greater_or_equal("this", 30), 2)
     self.assertEqual(self.map.values(predicate), [])
 def test_next_page(self):
     self.fill_map()
     predicate = paging(greater_or_equal('this', 40), 2)
     predicate.next_page()
     self.assertEqual(self.map.values(predicate), [42, 43])