def test_current_data_matches_new_data(self): data = b"data" self.zookeeper.set(TEST_NODE_PATH, data) input = BytesIO(data) did_write = write_file_to_zookeeper(self.zookeeper, input, TEST_NODE_PATH) self.assertFalse(did_write)
def test_successful_set(self): self.assertEqual(self.zookeeper.get(TEST_NODE_PATH)[0], b"") input = BytesIO(b"new_data") did_write = write_file_to_zookeeper(self.zookeeper, input, TEST_NODE_PATH) self.assertTrue(did_write) self.assertEqual(self.zookeeper.get(TEST_NODE_PATH)[0], b"new_data")
def test_compress(self): raw = b"test" compressed = publisher.gzip_compress(raw) decompressed = gzip.GzipFile(fileobj=BytesIO(compressed)).read() self.assertEqual(raw, decompressed)
def test_exits_when_node_does_not_exist(self): input = BytesIO() with self.assertRaises(NodeDoesNotExistError): write_file_to_zookeeper(self.zookeeper, input, "/does_not_exist")