Ejemplo n.º 1
0
    def test_file_is_as_directory(self, tmpdir, expected_post):
        tmpdir = Path(tmpdir)
        postsdir = (tmpdir / "posts").mkdir()
        filepath = (postsdir / "test_post").mkdir()
        expected_post.filepath = filepath

        codec = PostCodec(postsdir=postsdir)

        assert not codec.is_post(filepath)
        assert codec.is_publishable(filepath)

        with pytest.raises(IsADirectoryError):
            codec.dump_app_data(expected_post)

        with pytest.raises(IsADirectoryError):
            codec.load(filepath)
Ejemplo n.º 2
0
    def test_file_not_found(self, tmpdir, expected_post):
        tmpdir = Path(tmpdir)
        postsdir = (tmpdir / "posts").mkdir()
        filepath = postsdir / "test_post.md"
        expected_post.filepath = filepath

        codec = PostCodec(postsdir=postsdir)

        assert not codec.is_post(filepath)
        assert codec.is_publishable(filepath)

        with pytest.raises(FileNotFoundError):
            codec.dump_app_data(expected_post)

        with pytest.raises(FileNotFoundError):
            codec.load(filepath)