diff --git a/src/tests/test_overall.py b/src/tests/test_overall.py --- a/src/tests/test_overall.py +++ b/src/tests/test_overall.py @@ -17,14 +17,14 @@ handler = FileHandler("/tmp/morevna.log" handler.setFormatter(config.formatter) config.logger.addHandler(handler) -config.batchSize.hash = 8 -config.batchSize.data = 8 +config.batch_size.hash = 8 +config.batch_size.data = 8 -dataDir = os.path.join(config.directory, "src/tests/data") -filename = os.path.join(dataDir, "test.img") +data_dir = os.path.join(config.directory, "src/tests/data") +filename = os.path.join(data_dir, "test.img") -def compareFiles(f1, f2): +def compare_files(f1, f2): with open(f1, mode="rb") as f: h2 = hashlib.sha256(f.read()).hexdigest() with open(f2, mode="rb") as f: @@ -36,7 +36,7 @@ class TestMorevna(RedirectedOutput, Test _stdout = None def setUp(self): - src = os.path.join(dataDir, "test1.img") + src = os.path.join(data_dir, "test1.img") shutil.copyfile(src, filename) @classmethod @@ -45,15 +45,15 @@ class TestMorevna(RedirectedOutput, Test os.remove(filename) def test_build(self): - treeFile = os.path.join(dataDir, "test.bin") - refFile = os.path.join(dataDir, "test1.bin") + tree_file = os.path.join(data_dir, "test.bin") + ref_file = os.path.join(data_dir, "test1.bin") - tree = HashTree.fromFile(os.path.join(dataDir, "test1.img")) - tree.save(treeFile) + tree = HashTree.from_file(os.path.join(data_dir, "test1.img")) + tree.save(tree_file) - self.assertEqual(*compareFiles(refFile, treeFile)) + self.assertEqual(*compare_files(ref_file, tree_file)) - os.remove(treeFile) + os.remove(tree_file) def test_push(self): config.port += 1 @@ -61,35 +61,35 @@ class TestMorevna(RedirectedOutput, Test p = multiprocessing.Process(target=ms.serve) p.start() - for clientFile in ("test2.img", "test3.img", "test4.img"): - clientFile = os.path.join(dataDir, clientFile) - c = Client(clientFile) + for client_file in ("test2.img", "test3.img", "test4.img"): + client_file = os.path.join(data_dir, client_file) + c = Client(client_file) with ClientConnection("127.0.0.1", config.port) as con: - c.setConnection(con) + c.set_connection(con) c.init("push") - blocksToTransfer = c.negotiate() - c.sendData(blocksToTransfer) + blocks_to_transfer = c.negotiate() + c.send_data(blocks_to_transfer) - self.assertEqual(*compareFiles(clientFile, filename)) + self.assertEqual(*compare_files(client_file, filename)) p.terminate() p.join() def test_pull(self): config.port += 1 - serverFile = os.path.join(dataDir, "test3.img") - ms = Miniserver(serverFile) + server_file = os.path.join(data_dir, "test3.img") + ms = Miniserver(server_file) p = multiprocessing.Process(target=ms.serve) p.start() c = Client(filename) with ClientConnection("127.0.0.1", config.port) as con: - c.setConnection(con) + c.set_connection(con) c.init("pull") - blocksToTransfer = c.negotiate() - c.pullData(blocksToTransfer) + blocks_to_transfer = c.negotiate() + c.pull_data(blocks_to_transfer) - self.assertEqual(*compareFiles(serverFile, filename)) + self.assertEqual(*compare_files(server_file, filename)) p.terminate() p.join() @@ -100,17 +100,17 @@ class TestMorevna(RedirectedOutput, Test p = multiprocessing.Process(target=ms.serve) p.start() - c1 = Client(os.path.join(dataDir, "test2.img")) + c1 = Client(os.path.join(data_dir, "test2.img")) with ClientConnection("127.0.0.1", config.port) as con1: - c1.setConnection(con1) + c1.set_connection(con1) c1.init("push") - c2 = Client(os.path.join(dataDir, "test3.img")) + c2 = Client(os.path.join(data_dir, "test3.img")) with ClientConnection("127.0.0.1", config.port) as con2: - c2.setConnection(con2) + c2.set_connection(con2) with self.assertRaises(DeniedConnection): c2.init("push") - c1.sendData([]) # to unlock the server + c1.send_data([]) # to unlock the server p.terminate() p.join()