Beispiel #1
0
    def test_folder_structure_when_logging_is_not_enabled(self):
        with tempfile.TemporaryDirectory() as tmp_dir:
            path = Path(tmp_dir, self.folder_name)
            Request(path,
                    "bar",
                    mo.get_global_settings(),
                    save_on_creation=True,
                    enable_logging=False)

            utils.assert_folder_structure_equal(self.folder_structure, path)
Beispiel #2
0
    def test_saving(self):
        with tempfile.TemporaryDirectory() as tmd_dir:
            path = Path(tmd_dir, self.rel_dir)

            expected_files = {
                "mesu1.He.RBS_Cl.0.cut": None,
                "mesu1.He.RBS_Cl.1.cut": None,
                "mesu1.1He.RBS_He.0.cut": None,
                "mesu1.He.ERD.0.cut": None,
                "mesu1.He.ERD.1.cut": None,
                "mesu1.He.ERD.10.cut": None,
            }
            self._generate_cut_files(path)
            utils.assert_folder_structure_equal(expected_files, path)
Beispiel #3
0
    def test_folder_structure_when_logging_is_enabled(self):
        """Tests the folder structure when request is created"""
        with tempfile.TemporaryDirectory() as tmp_dir:
            path = Path(tmp_dir, self.folder_name)
            request = Request(path,
                              "bar",
                              mo.get_global_settings(),
                              save_on_creation=True,
                              enable_logging=True)

            folder_structure = {
                "request.log": None,
                **self.folder_structure,
            }
            utils.assert_folder_structure_equal(folder_structure, path)
            request.close_log_files()
Beispiel #4
0
    def test_rename_measurement(self):
        with tempfile.TemporaryDirectory() as tmp_dir:
            path = Path(tmp_dir)
            mesu_path = path / "mesu"
            mesu_name = "foo"
            measurement = Measurement(mo.get_request(),
                                      path=mesu_path / f"{mesu_name}.info",
                                      name=mesu_name,
                                      save_on_creation=False,
                                      enable_logging=False,
                                      use_request_settings=False)
            measurement.create_folder_structure(mesu_path)
            measurement.to_file()

            utils.assert_folder_structure_equal(
                get_extected_folder_structure("mesu", "foo"), path)

            measurement.rename("bar")

            utils.assert_folder_structure_equal(
                get_extected_folder_structure('Measurement_00-bar', "bar"),
                path)
Beispiel #5
0
    def test_folder_structure(self):
        """Tests the folder structure when request is created"""
        with tempfile.TemporaryDirectory() as tmp_dir:
            path = Path(tmp_dir, self.folder_name)
            Request(path,
                    "bar",
                    mo.get_global_settings(),
                    save_on_creation=False,
                    enable_logging=False)

            self.assertEqual([], os.listdir(tmp_dir))

            request = Request(path,
                              "bar",
                              mo.get_global_settings(),
                              save_on_creation=True,
                              enable_logging=False)

            utils.assert_folder_structure_equal(self.folder_structure, path)

            request.to_file()
            utils.assert_folder_structure_equal(self.folder_structure, path)

            utils.disable_logging()
Beispiel #6
0
    def test_folder_structure(self):
        with tempfile.TemporaryDirectory() as tmp_dir:
            path = Path(tmp_dir, self.mesu_folder)
            mesu = Measurement(
                mo.get_request(),
                path / f"{self.mesu_name}.info",
                name=self.mesu_name,
                measurement_setting_file_name=self.settings_file,
                save_on_creation=False,
                enable_logging=False,
                use_request_settings=False)

            # No files or folders should be created...
            utils.assert_folder_structure_equal({}, Path(tmp_dir))

            # ... until create_folder_structure is called
            mesu.create_folder_structure(path)
            utils.assert_folder_structure_equal(self.folder_structure,
                                                Path(tmp_dir))

            mesu.to_file()

            utils.assert_folder_structure_equal(self.after_to_file,
                                                Path(tmp_dir))