def test_to_page_method_to_page_one_from_two(request_mock):
    request_mock.return_value.text = RESPONSE2

    m = MunawwirScraper('lari', page=2)

    request_mock.return_value.text = RESPONSE1

    m1 = m.to_page(page=1)

    tools.eq_(m1.url, URL.format('lari', '1'))
def test_next_page(resp_mock):
    # response_pertama
    resp_mock.return_value.text = RESPONSE

    page_one = MunawwirScraper('lari')

    tools.eq_(RESPONSE, page_one.response)

    resp_mock.return_value.text = RESPONSE2

    page_two = page_one.next_page()

    tools.eq_(RESPONSE2, page_two.response)
def test_next_page_kalau_sudah_di_ujung(scraper_mock, resp_mock):
    resp_mock.return_value.text = RESPONSE

    # instance = scraper_mock
    # instance.current_page.return_value = 4

    scraper_mock.return_value = 4


    page_four = MunawwirScraper('lari')
    # page_four.current_page = MagicMock(return_value=4)

    tools.eq_(page_four.current_page, 4)


    page_four.next_page()
Example #4
0
def test_utama(req_mock):
    req_mock.return_value.text = RESPONSE

    nikah = MunawwirScraper('nikah')

    hasil = nikah.hasil()

    tools.eq_('nikah', hasil.indo)

    tools.eq_('*Diterjemahkan dengan Bing Translator', hasil.sumber)

    tools.eq_('رخصة الزواج', hasil.arab)

    tools.eq_(3, len(hasil.berhubungan))

    tools.eq_(None, hasil.baca)
Example #5
0
def test_get_pages(obj):
    obj.return_value.text = RESPONSE

    munawwir = MunawwirScraper('lari')

    tools.eq_(len(munawwir.pages), 4)

    tools.eq_(max(munawwir.pages), 'http://qaamus.com/indonesia-arab/lari/4')
Example #6
0
def test_hasil(munawwir_mock, obj):
    obj.return_value.text = RESPONSE

    berhubungan = MunawwirBerhubModelCollections((x for x in range(3)))
    munawwir_mock.return_value = berhubungan

    munawwir = MunawwirScraper('lari')

    expected = MunawwirModel(
        indo='lari',
        arab='عَدْوٌ ، جَرْيٌ ، عَدَا - يَعْدُوْ ، جَرَى - يَجْرِي',
        baca="adwun, jaryun, 'adaa - ya'duu, jaroo - yajrii",
        sumber=
        'Data diambil dari Kamus Al-Munawwir Edisi Indonesia Arab pada halaman 499',
        url='http://qaamus.com/indonesia-arab/lari/1',
        berhubungan=munawwir_mock)

    tools.eq_(munawwir.hasil().__dict__, expected.__dict__)
def test_hasil_next_page_berhub(resp_mock):
    # reponse pertama
    resp_mock.return_value.text = RESPONSE

    page_one = MunawwirScraper('lari')

    tools.eq_(page_one.current_page, 1)

    # response kedua

    resp_mock.return_value.text = RESPONSE2

    page_two = page_one.next_page()

    expected = MunawwirBerhubModel(indo='lari berantai', 
                                   arab='عَدْوٌ أَو جَرْيٌ بِتَسَلْسُلٍ', 
                                   url='http://qaamus.com/indonesia-arab/lari+berantai/1')

    tools.eq_(len(page_two.berhubungan), 10)
    tools.eq_(next(page_two.berhubungan).__dict__, expected.__dict__)
    tools.ok_(isinstance(page_two.berhubungan, MunawwirBerhubModelCollections))
Example #8
0
def test_berhubungan(obj):
    obj.return_value.text = RESPONSE

    munawwir = MunawwirScraper('lari')

    berhubungan = next(munawwir.berhubungan)

    expected = MunawwirBerhubModel(
        'lari berjingkrak-jingkrak',
        'خَاضَ - يَخُوْضُ الجَوَادُ فِـي الـمَيْدَانِ',
        'http://qaamus.com/indonesia-arab/Lari+berjingkrak-jingkrak/1'
    ).__dict__

    tools.eq_(berhubungan.__dict__, expected)
    tools.ok_(isinstance(munawwir.berhubungan, MunawwirBerhubModelCollections))
Example #9
0
def test_response(req_mock):
    req_mock.return_value.text = RESPONSE

    nikah = MunawwirScraper('nikah')

    tools.eq_(nikah.response, RESPONSE)
Example #10
0
def test_current_pagination(obj):
    obj.return_value.text = RESPONSE

    munawwir = MunawwirScraper('lari')

    tools.eq_(munawwir.current_page, 1)
Example #11
0
def test_has_pagination(obj):
    obj.return_value.text = RESPONSE

    munawwir = MunawwirScraper('lari')

    tools.ok_(munawwir.has_pagination)
Example #12
0
def test_check_pilihan(obj):
    tools.ok_(MunawwirScraper.check_pilihan('munawwir'))
Example #13
0
def test_response(obj):
    obj.return_value.text = RESPONSE

    munawwir = MunawwirScraper('lari')

    tools.eq_(RESPONSE, munawwir.response)
def test_current_page_with_page_two(request_mock):
    request_mock.return_value.text = RESPONSE2

    m = MunawwirScraper('lari', page=2)

    tools.eq_(m.current_page, 2)
def test_munawwir_scraper_param_page(request_mock):
    m = MunawwirScraper('lari', page=2)
    tools.eq_(m.url, URL.format('lari', '2'))
def test_default_page_is_one(request_mock):
    m = MunawwirScraper('lari')
    tools.eq_(m.url, URL.format('lari', '1'))