From 9a7a42d03adcf5dbb5927e986b2e7d8c781b1c43 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Mon, 22 Jul 2019 18:18:11 +0200 Subject: [PATCH] feat: comments --- replication_client.py | 26 +++++++++++++++++++++++--- test_replication.py | 6 ++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/replication_client.py b/replication_client.py index e6e8ad0..1f5526d 100644 --- a/replication_client.py +++ b/replication_client.py @@ -25,13 +25,25 @@ class Client(object): self._factory = factory def connect(self,address="127.0.0.1",port=5560): + """ + Connect to the server + """ self._net_client.connect(address=address,port=port) def disconnect(self): + """ + Disconnect from server, reset the client + """ self._net_client.stop() @property def state(self): + """ + Return the client state + 0: STATE_INITIAL + 1: STATE_SYNCING + 2: STATE_ACTIVE + """ return self._net_client.state def register(self, object): @@ -49,7 +61,7 @@ class Client(object): logger.info("Registering {} on {}".format(object,new_item.uuid)) new_item.store(self._rep_store) - logger.info("Pushing changes...") + logger.info("Pushing new registered value") new_item.push(self._net_client.publish) return new_item.uuid @@ -57,9 +69,17 @@ class Client(object): raise TypeError("Type not supported") def pull(self,object=None): + """ + Asynchonous pull + Here we want to pull all waiting changes and apply them + """ pass - def unregister(self,object): + def unregister(self,object_uuid): + """ + Unregister for replication the given + object + """ pass class ClientNetService(threading.Thread): @@ -259,7 +279,7 @@ class ServerNetService(threading.Thread): # Snapshot end self.snapshot.send(identity, zmq.SNDMORE) RepCommand(owner='server',pointer='SNAPSHOT_END').push(self.snapshot) - + # Regular update routing (Clients / Server / Clients) if self.pull in socks: diff --git a/test_replication.py b/test_replication.py index dca3493..a500186 100644 --- a/test_replication.py +++ b/test_replication.py @@ -159,13 +159,19 @@ class TestClient(unittest.TestCase): self.assertEqual(test_map_result.map["toto"], test_map["toto"]) + def suite(): suite = unittest.TestSuite() + + # Data factory suite.addTest(TestDataFactory('test_data_factory')) + + # Client suite.addTest(TestClient('test_empty_snapshot')) suite.addTest(TestClient('test_filled_snapshot')) suite.addTest(TestClient('test_register_client_data')) suite.addTest(TestClient('test_client_data_intergity')) + return suite if __name__ == '__main__':