Example #1
0
def test_different_date_parsing():
    abclinuxuapi.Blogpost(
        "http://abclinuxu.cz/clanky/yubikey.-co-to-je-a-co-to-umi-1",
        lazy=False)

    abclinuxuapi.Blogpost(
        "http://abclinuxu.cz/clanky/bezpecnost/ssl-je-vase-bezpecne-pripojeni-opravdu-zabezpecene",
        lazy=False)

    abclinuxuapi.Blogpost(
        "http://abclinuxu.cz/blog/jarasa/2016/10/i-pejsek-musi-jist-kvalitne",
        lazy=False)

    abclinuxuapi.Blogpost(
        "http://abclinuxu.cz/blog/msk/2016/8/hlada-sa-linux-embedded-vyvojar",
        lazy=False)

    blog = abclinuxuapi.Blogpost(
        "http://abclinuxu.cz/blog/Strider_BSD_koutek/2006/8/objevil-jsem-ameriku",
        lazy=False)
    assert len(blog.comments) == 0

    blog = abclinuxuapi.Blogpost(
        "http://www.abclinuxu.cz/blog/tucnak_viktor/2005/1/zdravim-nahodne-navstevniky",
        lazy=False)
Example #2
0
def test_constructor(bp_url):
    bp = abclinuxuapi.Blogpost(bp_url)

    assert bp.url == bp_url
    assert bp.uid is None
    assert bp.title is None
    assert bp.intro is None
    assert bp.text is None
    assert bp.rating is None
    assert bp.comments == []
    assert bp.comments_n == -1
    assert bp.created_ts is None
    assert bp.last_modified_ts is None
    assert bp.object_ts > 0
Example #3
0
def test_constructor_multi_params(bp_url):
    bp = abclinuxuapi.Blogpost(url=bp_url,
                               uid="uid",
                               title="title",
                               intro="intro",
                               text="text",
                               rating="rating",
                               comments="comments",
                               comments_n="comments_n",
                               created_ts="created_ts",
                               last_modified_ts="last_modified_ts",
                               object_ts="object_ts")

    assert bp.url == bp_url
    assert bp.uid == "uid"
    assert bp.title == "title"
    assert bp.intro == "intro"
    assert bp.text == "text"
    assert bp.rating == "rating"
    assert bp.comments == "comments"
    assert bp.comments_n == "comments_n"
    assert bp.created_ts == "created_ts"
    assert bp.last_modified_ts == "last_modified_ts"
    assert bp.object_ts == "object_ts"
Example #4
0
def test_constructor_wrong_params(bp_url):
    with pytest.raises(TypeError):
        bp = abclinuxuapi.Blogpost(bp_url, azgabash=True)
Example #5
0
        fn = os.path.join(os.path.dirname(__file__), "mock_data/blogpost.html")

        with open(fn) as f:
            return f.read()

    monkeypatch.setattr(abclinuxuapi.blogpost, "download", mock_download)


def setup_module(do_that_fucking_monkey_patch):
    """
    It is not possiblel to import monkeypatch from pytest. You have to use it
    as fixture.
    """


BPOST = abclinuxuapi.Blogpost(bp_url(), lazy=False)


@pytest.fixture
def bpost():
    """
    This may seem a little bit crazy, but this speeds up the testing 6x.

    I don't need new object for each test.
    """
    return BPOST


# Tests =======================================================================
def test_constructor(bp_url):
    bp = abclinuxuapi.Blogpost(bp_url)