def start(path): """ Starts the (branch) monitoring done through the cronjob. :param path: the repository to start monitoring on """ config = Configuration(file_name="repositories") config.add(path) print(f"Started monitoring of {path}")
class TestConfig(unittest.TestCase): def setUp(self) -> None: self.path = os.path.dirname(os.path.realpath(__file__)) self.name = "test_file" self.config = Configuration(self.path, self.name) def tearDown(self) -> None: os.remove(self.config.path()) def test_add(self) -> None: expected = "/home/rednoss/Documents/Workspace/repository-monitoring" self.config.add(expected) with open(self.config.path(), "r") as f: self.assertEqual(f"- {expected}\n", f.read()) def test_read(self) -> None: path = "/home/rednoss/Documents/Workspace/repository-monitoring" self.config.add(path) self.assertEqual(str(self.config.read()), f"['{path}']") def test_remove(self) -> None: path = "/home/rednoss/Documents/Workspace/repository-monitoring" self.config.add(path) self.config.remove(path) with open(self.config.path(), "r") as f: self.assertEqual("[]\n", str(f.read()))