Ejemplo n.º 1
0
def cli(home=None, automated=True):
    if not home:
        msg = "Hi there! What folder should we set as the home of your blog?"
        home = questionary.text(msg, default=Config().home_folder).ask()

    cfg = Config(home=home, automated=automated)
    blogger = Blogger(cfg)
    blogger.run()

    print("All done!")
Ejemplo n.º 2
0
    def test_it_raises_specific_when_folder_not_found(self, cfg):
        content = ConvertedContent(cfg=cfg,
                                   path="/",
                                   content="",
                                   metadata={"folder": "key_for_folder_one"})

        # Config uses provided bnote_settings_file in tests/data, all good
        assert content.folder

        # Config without mapping file
        new_cfg = Config()
        content.cfg = new_cfg

        with pytest.raises(FolderCouldNotBeMapped):
            content.folder

        # Remove folder from metadata so nothing can be found
        content.cfg = cfg
        content.metadata = {}
        with pytest.raises(FolderCouldNotBeMapped):
            content.folder

        content.metadata["folder"] = "THIS FOLDER DOES NOT EXIST"
        with pytest.raises(FolderCouldNotBeMapped):
            content.folder
Ejemplo n.º 3
0
    def test_init_options_have_default_values(self, count):
        cfg = Config()

        option = _defaults[count]
        val = getattr(cfg, option.key)

        assert val == option.default
        assert option.default == option.value
Ejemplo n.º 4
0
    def test_init_options_get_env_var_as_value(self, cfg_name, monkeypatch):
        monkeypatch.setenv(cfg_name, "New value not in defaults!")
        option = next(co for co in _defaults if co.name == cfg_name)

        cfg = Config()
        val = getattr(cfg, option.key)

        assert val == option.value
        assert option.default != option.value
Ejemplo n.º 5
0
    def test_init_kwargs_can_override_defaults(self):
        option = _defaults[0]
        kwargs = {option.key: "new_value_not_in_defaults"}

        cfg = Config(**kwargs)
        val = getattr(cfg, option.key)

        assert val == "new_value_not_in_defaults"
        assert val != option.value
        assert val != option.default
Ejemplo n.º 6
0
def cfg():
    return Config(bnote_settings_file=TEST_DATA_DIR / TEST_BNOTE)
Ejemplo n.º 7
0
 def __init__(self, config=None):
     self.cfg = config or Config()
Ejemplo n.º 8
0
 def __init__(self, config=None):
     self.cfg = config or Config()
     self.md = markdown.Markdown(output_format="html",
                                 extensions=["fenced_code"])
Ejemplo n.º 9
0
    def test_reading_bnote_settings_raises_folder_could_not_be_mapped(self):
        cfg = Config()

        with pytest.raises(FolderCouldNotBeMapped):
            cfg.read_boostnote_settings()
Ejemplo n.º 10
0
    def test_init_can_set_new_options(self):
        cfg = Config(spullekes="dingens")

        assert hasattr(cfg, "spullekes")
        assert cfg.spullekes == "dingens"
Ejemplo n.º 11
0
    def test_init_has_options(self):
        cfg = Config()

        assert hasattr(cfg, "markdown_open")
        assert hasattr(cfg, "metadata_extension")
Ejemplo n.º 12
0
    def settings_file_cfg(self, tmp_path):
        option = next(co for co in _defaults if co.name == "BNOTE_SETTINGS_FILE")
        settings_file = tmp_path / option.value
        settings_file.write_text(json.dumps(self.content))

        return Config(bnote_settings_file=settings_file)