def test_get_pagination_pages():
    soup = build_beautiful_soup_from_path('sample/sample_category.html')
    parser = CategoryPageParser(soup)

    links = parser.get_pagination_pages()
    assert list(links) == [
        "http://p30download.com/fa/ebook/category/literary/page/2", "http://p30download.com/fa/ebook/category/literary/page/3",
        "http://p30download.com/fa/ebook/category/literary/page/4", "http://p30download.com/fa/ebook/category/literary/page/5",
        "http://p30download.com/fa/ebook/category/literary/page/17"
    ]
def test_get_post_links():
    soup = build_beautiful_soup_from_path('sample/sample_category.html')
    parser = CategoryPageParser(soup)

    links = parser.get_post_links()
    assert list(links) == [
        "http://p30download.com/fa/entry/53201/", "http://p30download.com/fa/entry/53304/",
        "http://p30download.com/fa/entry/50296/", "http://p30download.com/fa/entry/53035/",
        "http://p30download.com/fa/entry/52929/", "http://p30download.com/fa/entry/52780/",
        "http://p30download.com/fa/entry/52677/", "http://p30download.com/fa/entry/52430/",
        "http://p30download.com/fa/entry/51855/"]
Example #3
0
def test_get_pagination_pages():
    soup = build_beautiful_soup_from_path('sample/sample_category.html')
    parser = CategoryPageParser(soup)

    links = parser.get_pagination_pages()
    assert list(links) == [
        "http://p30download.com/fa/ebook/category/literary/page/2",
        "http://p30download.com/fa/ebook/category/literary/page/3",
        "http://p30download.com/fa/ebook/category/literary/page/4",
        "http://p30download.com/fa/ebook/category/literary/page/5",
        "http://p30download.com/fa/ebook/category/literary/page/17"
    ]
Example #4
0
def test_get_post_links():
    soup = build_beautiful_soup_from_path('sample/sample_category.html')
    parser = CategoryPageParser(soup)

    links = parser.get_post_links()
    assert list(links) == [
        "http://p30download.com/fa/entry/53201/",
        "http://p30download.com/fa/entry/53304/",
        "http://p30download.com/fa/entry/50296/",
        "http://p30download.com/fa/entry/53035/",
        "http://p30download.com/fa/entry/52929/",
        "http://p30download.com/fa/entry/52780/",
        "http://p30download.com/fa/entry/52677/",
        "http://p30download.com/fa/entry/52430/",
        "http://p30download.com/fa/entry/51855/"
    ]
def test_get_post_href():
    soup = build_beautiful_soup_from_path('sample/sample_post.html')
    post = PostPageParser.parser_factory(soup)

    url = 'http://p30download.com/fa/entry/35912/'
    name = u'دانلود Ubuntu v14.04.1 x86/x64 - لینوکس اوبونتو'
    views = '217,150'
    category = u'نرم افزار/سیستم عامل/لینوکس'
    description = u'''Ubuntu نمونه توضیح کوتاه شده برات تست بهتر'''
    specifications = {
        u'امتیاز': '<img class="image-middle" src="http://p30download.com/template/images/4.5-star.gif"/>',
        u'تاریخ انتشار': '09:59 - 93/5/12',
        u'حجم فایل': u'753.3 + 763 مگابایت',
        u'منبع': u'پی سی دانلود',
    }
    download_links = [
        'http://ftp.ticklers.org/releases.ubuntu.org/releases//14.04.1/ubuntu-14.04.1-desktop-i386.iso',
        'http://ftp.acc.umu.se/mirror/ubuntu-releases/14.04.1/ubuntu-14.04.1-desktop-amd64.iso',
    ]
    assert post.url == url
    assert post.name == name
    assert post.views == views
    assert post.category == category
    assert post.description == description
    assert post.specification == specifications
    assert list(post.download_links) == download_links

    assert json.loads(post.jsonify()) == {
        'URL': url,
        'name': name,
        'views': views,
        'category': category,
        'description': description,
        'specifications': specifications,
        'download_links': download_links,
    }
def test_get_post_href():
    soup = build_beautiful_soup_from_path("sample/sample_post.html")
    post = PostPageParser.parser_factory(soup)

    url = "http://p30download.com/fa/entry/35912/"
    name = u"دانلود Ubuntu v14.04.1 x86/x64 - لینوکس اوبونتو"
    views = "217,150"
    category = u"نرم افزار/سیستم عامل/لینوکس"
    description = u"""Ubuntu نمونه توضیح کوتاه شده برات تست بهتر"""
    specifications = {
        u"امتیاز": '<img class="image-middle" src="http://p30download.com/template/images/4.5-star.gif"/>',
        u"تاریخ انتشار": "09:59 - 93/5/12",
        u"حجم فایل": u"753.3 + 763 مگابایت",
        u"منبع": u"پی سی دانلود",
    }
    download_links = [
        "http://ftp.ticklers.org/releases.ubuntu.org/releases//14.04.1/ubuntu-14.04.1-desktop-i386.iso",
        "http://ftp.acc.umu.se/mirror/ubuntu-releases/14.04.1/ubuntu-14.04.1-desktop-amd64.iso",
    ]
    assert post.url == url
    assert post.name == name
    assert post.views == views
    assert post.category == category
    assert post.description == description
    assert post.specification == specifications
    assert list(post.download_links) == download_links

    assert json.loads(post.jsonify()) == {
        "URL": url,
        "name": name,
        "views": views,
        "category": category,
        "description": description,
        "specifications": specifications,
        "download_links": download_links,
    }