Repository: hazelcast/hazelcast-python-client

Issue:
Implement ObjectDataInput#skip_bytes
It seems that we didn't implement `skip_bytes` method yet. We should do that similar to the Java client.

https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/ByteArrayObjectDataInput.java#L598

Discussion:
mdumandag: verify

Patch:
diff --git a/hazelcast/serialization/input.py b/hazelcast/serialization/input.py
index dcc68ca..cc6c387 100644
--- a/hazelcast/serialization/input.py
+++ b/hazelcast/serialization/input.py
@@ -36,7 +36,14 @@ class _ObjectDataInput(ObjectDataInput):
         self._pos += _len
 
     def skip_bytes(self, count):
-        raise NotImplementedError("skip_bytes not implemented!!!")
+        if count <= 0:
+            return 0
+
+        if self._pos + count > self._size:
+            count = self._size - self._pos
+
+        self._pos += count
+        return count
 
     def read_boolean(self, position=None):
         return self.read_byte(position) != 0


Test patch:
diff --git a/tests/serialization/input_test.py b/tests/serialization/input_test.py
index 71ae9a6..c17da70 100644
--- a/tests/serialization/input_test.py
+++ b/tests/serialization/input_test.py
@@ -51,6 +51,21 @@ class InputTestCase(unittest.TestCase):
         self.assertEqual(0, initial_pos)
         self.assertEqual(six.unichr(0x00e7), char)
 
+    def test_skip_bytes(self):
+        inp = _ObjectDataInput(bytearray(10))
+        self.assertEqual(0, inp.position())
+        self.assertEqual(4, inp.skip_bytes(4))
+        self.assertEqual(4, inp.position())
 
-if __name__ == '__main__':
-    unittest.main()
+    def test_skip_bytes_when_count_greater_than_remaining(self):
+        inp = _ObjectDataInput(bytearray(10))
+        inp.set_position(8)
+        self.assertEqual(2, inp.skip_bytes(4))
+        self.assertEqual(10, inp.position())
+
+    def test_skip_bytes_when_count_is_not_positive(self):
+        inp = _ObjectDataInput(bytearray(10))
+        self.assertEqual(0, inp.skip_bytes(0))
+        self.assertEqual(0, inp.position())
+        self.assertEqual(0, inp.skip_bytes(-1))
+        self.assertEqual(0, inp.position())