Exemplo n.º 1
0
    def test_unreadable_directory(self):
        """
        Given an invalid directory (chmod 000), ensure the correct error is thown
        :return:
        """
        directory = path.join(path_to_module, "inaccessible_dir")

        with self.assertRaises(DirectoryError) as context:
            Parser.get_sample_sheet(directory)

        self.assertEqual(context.exception.directory, directory)
Exemplo n.º 2
0
    def test_no_sheet_in_directory(self):
        """
        Given an invalid directory, ensure an error is thrown
        :return:
        """
        directory = path.join(path_to_module, "three_dirs", "third")

        with self.assertRaises(DirectoryError) as context:
            Parser.get_sample_sheet(directory)

        self.assertEqual(context.exception.directory, directory)
Exemplo n.º 3
0
    def test_invalid_sample_sheets(self):
        """
        Given an invalid sample sheet, ensure the correct errors are included in the validation result
        :return:
        """
        sample_sheet = path.join(path_to_module, "invalid_sample_sheet",
                                 "SampleSheet.csv")

        with self.assertRaises(ValidationError) as context:
            Parser.get_sequencing_run(sample_sheet)

        validation_result = context.exception.validation_result
        self.assertEqual(type(validation_result), model.ValidationResult)

        for error in validation_result.error_list:
            self.assertEqual(type(error), SampleSheetError)
Exemplo n.º 4
0
 def setUp(self):
     print("\nStarting " + self.__module__ + ": " + self._testMethodName)
     # make a sequencing run that we can work with in the tests
     sheet_file = path.join(path_to_module, "fake_ngs_data",
                            "SampleSheet.csv")
     global sequencing_run
     sequencing_run = Parser.get_sequencing_run(sheet_file)
Exemplo n.º 5
0
    def test_find_none(self):
        """
        Given a directory with no sequencing run directories in it, make sure an empty list is returned
        :return:
        """
        directory = path.join(path_to_module, "no_dirs")
        res = Parser._find_directory_list(directory)

        self.assertEqual(res, [])
Exemplo n.º 6
0
    def test_find_none(self):
        """
        Given a directory with no run directories in it, return a empty list
        :return:
        """
        directory = path.join(path_to_module, "no_dirs")

        res = Parser.find_runs(directory)

        self.assertEqual(res, [])
Exemplo n.º 7
0
    def test_valid_run(self):
        """
        Given a valid sample sheet, ensure a sequencing run is created
        :return:
        """
        sample_sheet = path.join(path_to_module, "fake_ngs_data",
                                 "SampleSheet.csv")

        res = Parser.get_sequencing_run(sample_sheet)

        self.assertEqual(type(res), model.SequencingRun)
Exemplo n.º 8
0
    def test_valid_directory(self):
        """
        test the file path of a valid sequencing run is gotten correctly
        :return:
        """
        directory = path.join(path_to_module, "three_dirs", "first")
        file_path = path.join(directory, "SampleSheet.csv")

        res = Parser.get_sample_sheet(directory)

        self.assertEqual(res, file_path)
Exemplo n.º 9
0
    def test_find_dir(self):
        """
        Given a valid run directory, show as new
        :return:
        """
        directory = path.join(path_to_module, "three_dirs", "first")

        res = Parser.find_single_run(directory)

        self.assertEqual(type(res), model.DirectoryStatus)
        self.assertEqual(res.status, "new")
        self.assertEqual(res.directory, directory)
Exemplo n.º 10
0
    def test_find_none(self):
        """
        Given a directory with nothing in it, show as invalid
        :return:
        """
        directory = path.join(path_to_module, "no_dirs")

        res = Parser.find_single_run(directory)

        self.assertEqual(type(res), model.DirectoryStatus)
        self.assertEqual(res.status, "invalid")
        self.assertEqual(res.directory, directory)
Exemplo n.º 11
0
    def test_find_in_dir_with_three_dirs(self):
        """
        Given a directory with directories in it (but no actual run at highest level), show as invalid
        :return:
        """
        directory = path.join(path_to_module, "three_dirs")

        res = Parser.find_single_run(directory)

        self.assertEqual(type(res), model.DirectoryStatus)
        self.assertEqual(res.status, "invalid")
        self.assertEqual(res.directory, directory)
Exemplo n.º 12
0
    def test_find_three(self):
        """
        Given a directory with 3 run directories in it, make sure all 3 directories are included in result
        :return:
        """
        directory = path.join(path_to_module, "three_dirs")
        dir_1 = path.join(directory, "first")
        dir_2 = path.join(directory, "second")
        dir_3 = path.join(directory, "third")
        res = Parser._find_directory_list(directory)

        self.assertIn(dir_1, res)
        self.assertIn(dir_2, res)
        self.assertIn(dir_3, res)
Exemplo n.º 13
0
    def test_find_one_of_three(self):
        """
        Given a directory with 3 potential run directories in it, determine which are new and invalid
        :return:
        """
        directory = path.join(path_to_module, "three_dirs")
        dir_1 = path.join(directory, "first")
        dir_2 = path.join(directory, "second")
        dir_3 = path.join(directory, "third")
        correct_dirs = [dir_1, dir_2, dir_3]

        res = Parser.find_runs(directory)

        self.assertIn(res[0].directory, correct_dirs)
        self.assertIn(res[1].directory, correct_dirs)
        self.assertIn(res[2].directory, correct_dirs)

        for c_dir in res:
            if c_dir.directory == dir_1:
                self.assertEqual(c_dir.status, "new")
            elif c_dir.directory == dir_2:
                self.assertEqual(c_dir.status, "invalid")
            elif c_dir.directory == dir_3:
                self.assertEqual(c_dir.status, "invalid")