def test_get_and_alter(self):
     # the class is defined in the 4.1 JAR
     skip_if_server_version_older_than(self, self.client, "4.1")
     self.atomic_long.set(123)
     self.assertEqual(123,
                      self.atomic_long.get_and_alter(Multiplication(-1)))
     self.assertEqual(-123, self.atomic_long.get())
 def test_datetime_date(self):
     skip_if_client_version_older_than(self, "5.0")
     skip_if_server_version_older_than(self, self.client, "5.0")
     value = datetime.datetime.now().date()
     self.map.set("key", value)
     self.assertEqual(value, self.map.get("key"))
     response = self.get_from_server()
     self.assertEqual(response, value.strftime("%Y-%m-%d"))
 def test_local_date_time_from_server(self):
     skip_if_client_version_older_than(self, "5.0")
     skip_if_server_version_older_than(self, self.client, "5.0")
     self.assertTrue(
         self.set_on_server(
             "java.time.LocalDateTime.of(2021, 8, 24, 0, 59, 55, 987654000)"
         ))
     self.assertEqual(datetime.datetime(2021, 8, 24, 0, 59, 55, 987654),
                      self.map.get("key"))
 def test_offset_date_time_from_server(self):
     skip_if_client_version_older_than(self, "5.0")
     skip_if_server_version_older_than(self, self.client, "5.0")
     self.assertTrue(
         self.set_on_server(
             "java.time.OffsetDateTime.of(2021, 8, 24, 0, 59, 55, 987654000, "
             "java.time.ZoneOffset.ofTotalSeconds(2400))"))
     self.assertEqual(
         datetime.datetime(
             2021, 8, 24, 0, 59, 55, 987654,
             datetime.timezone(datetime.timedelta(seconds=2400))),
         self.map.get("key"),
     )
Ejemplo n.º 5
0
    def test_provided_suggestions(self):
        skip_if_client_version_older_than(self, "5.0")
        skip_if_server_version_older_than(self, self.client, "5.0")

        # We don't create a mapping intentionally to get suggestions
        self.map.put(1, "value-1")
        select_all_query = 'SELECT * FROM "%s"' % self.map_name
        with self.assertRaises(HazelcastSqlError) as cm:
            self.execute(select_all_query)

        self.execute(cm.exception.suggestion)

        with self.execute(select_all_query) as result:
            self.assertEqual(
                [(1, "value-1")],
                [(r.get_object("__key"), r.get_object("this"))
                 for r in result],
            )
    def test_datetime_time(self):
        skip_if_client_version_older_than(self, "5.0")
        skip_if_server_version_older_than(self, self.client, "5.0")
        value = datetime.datetime.now()
        if value.microsecond % 1000 == 0:
            # A little hack for Windows. Time is precise to the
            # milliseconds there. If we send the microseconds
            # we have now, due to trailing zeros, get_from_server()
            # call below will return the string representation with
            # 3 digits for the microseconds. But, Python always expects
            # 6 digits. So, the assertion will fail. To fix that,
            # we add 1 microseconds to the value, so that in the Java
            # side, nanoseconds representation will only have 3 trailing
            # zeros, and will send the data as we want.
            value = value + datetime.timedelta(microseconds=1)
        value = value.time()

        self.map.set("key", value)
        self.assertEqual(value, self.map.get("key"))
        response = self.get_from_server()
        self.assertEqual(response, value.strftime("%H:%M:%S.%f"))
 def test_local_time_from_server(self):
     skip_if_client_version_older_than(self, "5.0")
     skip_if_server_version_older_than(self, self.client, "5.0")
     self.assertTrue(
         self.set_on_server("java.time.LocalTime.of(18, 3, 35)"))
     self.assertEqual(datetime.time(18, 3, 35), self.map.get("key"))
 def test_local_date_from_server(self):
     skip_if_client_version_older_than(self, "5.0")
     skip_if_server_version_older_than(self, self.client, "5.0")
     self.assertTrue(
         self.set_on_server("java.time.LocalDate.of(2000, 12, 15)"))
     self.assertEqual(datetime.date(2000, 12, 15), self.map.get("key"))
 def test_apply(self):
     # the class is defined in the 4.1 JAR
     skip_if_server_version_older_than(self, self.client, "4.1")
     self.atomic_long.set(42)
     self.assertEqual(84, self.atomic_long.apply(Multiplication(2)))
     self.assertEqual(42, self.atomic_long.get())
 def test_alter(self):
     # the class is defined in the 4.1 JAR
     skip_if_server_version_older_than(self, self.client, "4.1")
     self.atomic_long.set(2)
     self.assertIsNone(self.atomic_long.alter(Multiplication(5)))
     self.assertEqual(10, self.atomic_long.get())
Ejemplo n.º 11
0
 def setUp(self):
     skip_if_server_version_older_than(self, self.client, "5.0")
Ejemplo n.º 12
0
 def _setup_skip_condition(self):
     skip_if_server_version_older_than(self, self.client, "4.2")
Ejemplo n.º 13
0
 def setUp(self):
     skip_if_server_version_older_than(self, self.client, "4.2")
     skip_if_server_version_newer_than_or_equal(self, self.client, "5.0")