コード例 #1
0
    def test_monitored_directory_validates(self):
        configuration_svc = dict()
        configuration_svc["monitored_directories"] = ["/data/testarteria1/runfolders"]
        runfolder_svc = RunfolderService(configuration_svc, logger)

        runfolder = "/data/testarteria1/runfolders/runfolder1"
        # passes if no exception:
        runfolder_svc._validate_is_being_monitored(runfolder)

        # Doesn't matter if the configuration specifies an extra separator:
        configuration_svc["monitored_directories"] = ["/data/testarteria1/runfolders/"]
        runfolder_svc._validate_is_being_monitored(runfolder)
コード例 #2
0
    def test_list_available_runfolders(self):
        # Setup
        configuration_svc = {
            "monitored_directories":
            ["/data/testarteria1/mon1", "/data/testarteria1/mon2"],
            "completed_marker_file":
            "RTAComplete.txt"
        }
        runfolder_svc = RunfolderService(configuration_svc, logger)

        runfolder_svc._file_exists = self._valid_runfolder
        runfolder_svc._file_exists_and_is_older_than = self._is_older_wrapper
        runfolder_svc._subdirectories = lambda path: ["runfolder001"]
        runfolder_svc._host = lambda: "localhost"

        # Test
        runfolders = runfolder_svc.list_available_runfolders()
        runfolders = list(runfolders)
        self.assertEqual(len(runfolders), 2)

        runfolders_str = sorted([str(runfolder) for runfolder in runfolders])
        expected = [
            "ready: /data/testarteria1/mon1/runfolder001@localhost",
            "ready: /data/testarteria1/mon2/runfolder001@localhost"
        ]
        self.assertEqual(runfolders_str, expected)
コード例 #3
0
    def test_next_runfolder(self):
        # Setup
        configuration_svc = {
            "monitored_directories": [
                "/data/testarteria1/mon1"
            ]
        }

        # Since keys in configuration_svc can be directly indexed, we can mock it with a dict:
        runfolder_svc = RunfolderService(configuration_svc, logger)
        runfolder_svc._file_exists = self._valid_runfolder
        runfolder_svc._subdirectories = lambda path: ["runfolder001"]
        runfolder_svc._host = lambda: "localhost"

        # Test
        runfolder = runfolder_svc.next_runfolder()
        expected = "READY: /data/testarteria1/mon1/runfolder001@localhost"
        self.assertEqual(str(runfolder), expected)
コード例 #4
0
    def test_list_available_runfolders(self):
        # Setup
        configuration_svc = {
            "monitored_directories": [
                "/data/testarteria1/mon1",
                "/data/testarteria1/mon2"
            ]
        }
        runfolder_svc = RunfolderService(configuration_svc, logger)

        runfolder_svc._file_exists = self._valid_runfolder
        runfolder_svc._subdirectories = lambda path: ["runfolder001"]
        runfolder_svc._host = lambda: "localhost"

        # Test
        runfolders = runfolder_svc.list_available_runfolders()
        runfolders = list(runfolders)
        self.assertEqual(len(runfolders), 2)

        runfolders_str = sorted([str(runfolder) for runfolder in runfolders])
        expected = ["READY: /data/testarteria1/mon1/runfolder001@localhost",
                    "READY: /data/testarteria1/mon2/runfolder001@localhost"]
        self.assertEqual(runfolders_str, expected)
コード例 #5
0
    def test_next_runfolder(self):
        # Setup
        configuration_svc = {
            "monitored_directories": ["/data/testarteria1/mon1"],
            "completed_marker_file": "RTAComplete.txt"
        }

        # Since keys in configuration_svc can be directly indexed, we can mock it with a dict:
        runfolder_svc = RunfolderService(configuration_svc, logger)
        runfolder_svc._file_exists = self._valid_runfolder
        runfolder_svc._file_exists_and_is_older_than = self._is_older_wrapper
        runfolder_svc._subdirectories = lambda path: ["runfolder001"]
        runfolder_svc._host = lambda: "localhost"

        # Test
        runfolder = runfolder_svc.next_runfolder()
        expected = "ready: /data/testarteria1/mon1/runfolder001@localhost"
        self.assertEqual(str(runfolder), expected)
コード例 #6
0
    def test_monitored_directory_validates(self):
        configuration_svc = dict()
        configuration_svc["monitored_directories"] = [
            "/data/testarteria1/runfolders"
        ]
        runfolder_svc = RunfolderService(configuration_svc, logger)

        runfolder = "/data/testarteria1/runfolders/runfolder1"
        # passes if no exception:
        runfolder_svc._validate_is_being_monitored(runfolder)

        # Doesn't matter if the configuration specifies an extra separator:
        configuration_svc["monitored_directories"] = [
            "/data/testarteria1/runfolders/"
        ]
        runfolder_svc._validate_is_being_monitored(runfolder)