Exemple #1
0
    def test_load_from_yaml(self):
        cfg = config.Config()
        cfg.load_from_yaml("name: project-1")
        self.assertEqual("project-1", cfg.name)
        self.assertEqual("project-1", cfg.archive_name)
        self.assertEqual("Export", cfg.export_dir)
        self.assertFalse(cfg.append_date)

        cfg = config.Config()
        cfg.load_from_yaml("name: project-1\narchive: proj1")
        self.assertEqual("proj1", cfg.archive_name)

        cfg = config.Config()
        cfg.load_from_yaml(
            "name: project-1\narchive: proj1\nappend_date: true")
        self.assertTrue(cfg.append_date)
Exemple #2
0
    def test_load_from_cli_args(self):
        args = cli.parse_args(
            ["pack", "--archive-name", "proj.zip", "--append-date"])
        cfg = config.Config()
        cfg.archive_name = "should override"
        cfg.append_date = False
        cfg.load_from_cli_args(args)

        self.assertEqual("proj-2020-01-02", cfg.archive_name)
        self.assertTrue(cfg.append_date)
Exemple #3
0
 def test_append_date_appends_date_to_archive_name(self):
     cfg = config.Config()
     cfg.archive_name = "xyz"
     cfg.append_date = True
     self.assertEqual("xyz-2020-01-01", cfg.archive_name)
Exemple #4
0
 def test_extension_is_stripped_from_archivename(self):
     cfg = config.Config()
     cfg.archive_name = "stems.zip"
     self.assertEqual("stems", cfg.archive_name)
Exemple #5
0
 def test_default_config(self):
     cfg = config.Config()
     self.assertEqual("unnamed", cfg.name)
     self.assertEqual("unnamed", cfg.archive_name)
     self.assertEqual("Export", cfg.export_dir)
     self.assertFalse(cfg.append_date)
Exemple #6
0
def __read_config(filename):
    with open(filename, "r") as config_file:
        cfg = config.Config()
        cfg.load_from_yaml(config_file)
        return cfg