Example #1
0
    def test_write_then_read_as_nullable(self, _, field_kind,
                                         nullable_field_kind):
        map_name = random_string()
        field_name = field_kind.name.lower()
        self._put_entry(
            map_name=map_name,
            value_to_put=REFERENCE_OBJECTS[field_kind],
            field_name=field_name,
        )
        nullable_method_suffix = nullable_field_kind.name.lower()
        client = self.create_client({
            "cluster_name":
            self.cluster.id,
            "compact_serializers": [
                SomeFieldsSerializer([
                    FieldDefinition(
                        name=field_name,
                        reader_method_name=f"read_{nullable_method_suffix}",
                    )
                ]),
            ],
        })

        m = client.get_map(map_name).blocking()
        obj = m.get("key")
        self.assertTrue(
            is_equal(REFERENCE_OBJECTS[field_kind], getattr(obj, field_name)))
Example #2
0
 def __eq__(self, other):
     return (
         isinstance(other, APortable)
         and self.boolean == other.boolean
         and self.b == other.b
         and self.c == other.c
         and self.d == other.d
         and self.s == other.s
         and is_equal(self.f, other.f)
         and self.i == other.i
         and self.l == other.l
         and self.bytes_size == other.bytes_size
         and self.unsigned_byte == other.unsigned_byte
         and self.unsigned_short == other.unsigned_short
         and self.string == other.string
         and self.p == other.p
         and self.booleans == other.booleans
         and self.bytes_ == other.bytes_
         and self.chars == other.chars
         and self.doubles == other.doubles
         and self.shorts == other.shorts
         and is_equal(self.floats, other.floats)
         and self.ints == other.ints
         and self.longs == other.longs
         and self.strings == other.strings
         and self.portables == other.portables
         and self.booleans_none == other.booleans_none
         and self.bytes_none == other.bytes_none
         and self.chars_none == other.chars_none
         and self.doubles_none == other.doubles_none
         and self.shorts_none == other.shorts_none
         and self.floats_none == other.floats_none
         and self.ints_none == other.ints_none
         and self.longs_none == other.longs_none
         and self.strings_none == other.strings_none
         and self.bytes_fully == other.bytes_fully
         and self.bytes_offset == other.bytes_offset
         and self.str_chars == other.str_chars
         and self.str_bytes == other.str_bytes
         and self.identified == other.identified
         and self.custom_serializable == other.custom_serializable
         and self.custom_byte_array_serializable == other.custom_byte_array_serializable
         and self.data == other.data
     )
Example #3
0
 def test_write_then_read(self, _, field_kind):
     field_name = field_kind.name.lower()
     m = self._put_entry(
         map_name=random_string(),
         value_to_put=REFERENCE_OBJECTS[field_kind],
         field_name=field_name,
     )
     obj = m.get("key")
     self.assertTrue(
         is_equal(REFERENCE_OBJECTS[field_kind], getattr(obj, field_name)))
Example #4
0
 def test_write_array_with_none_items_then_read(self, _, field_kind):
     field_name = field_kind.name.lower()
     value = [None] + REFERENCE_OBJECTS[field_kind] + [None]
     value.insert(2, None)
     m = self._put_entry(
         map_name=random_string(),
         value_to_put=value,
         field_name=field_name,
     )
     obj = m.get("key")
     self.assertTrue(is_equal(value, getattr(obj, field_name)))
Example #5
0
 def test_write_then_read_with_default_value(self, _, field_kind):
     field_name = field_kind.name.lower()
     m = self._put_entry(
         map_name=random_string(),
         value_to_put=REFERENCE_OBJECTS[field_kind],
         field_name=field_name,
         reader_method_name=f"read_{field_name}_or_default",
         default_value_to_read=object(),
     )
     obj = m.get("key")
     self.assertTrue(
         is_equal(REFERENCE_OBJECTS[field_kind], getattr(obj, field_name)))
Example #6
0
    def _write_then_read0(self, fields: typing.Dict[str, typing.Any],
                          serializer: CompactSerializer):
        client = self.create_client({
            "cluster_name":
            self.cluster.id,
            "compact_serializers": [serializer, NestedSerializer()],
        })

        m = client.get_map(random_string()).blocking()
        m.put("key", SomeFields(**fields))
        obj = m.get("key")
        for name, value in fields.items():
            self.assertTrue(is_equal(value, getattr(obj, name)))
Example #7
0
 def __eq__(self, other):
     return (
         isinstance(other, CustomByteArraySerializable)
         and self.i == other.i
         and is_equal(self.f, other.f)
     )
Example #8
0
 def __eq__(self, other):
     return (
         isinstance(other, AnInnerPortable) and self.i == other.i and is_equal(self.f, other.f)
     )