Exemplo n.º 1
0
def test_get_poetry_title():

    r3 = get_poetry('title', "A Lover's Complaint", 'author,title,linecount')

    assert r3[0]['author'] == 'William Shakespeare'
    assert r3[0]['linecount'] == 331
    assert r3[0]['title'] == "A Lover's Complaint"

    r4 = get_poetry('title', "Orpheus with his Lute Made Trees",
                    'author,title,linecount')

    assert r4[0]['author'] == 'William Shakespeare'
    assert r4[0]['linecount'] == 12
    assert r4[0]['title'] == 'Orpheus with his Lute Made Trees'
Exemplo n.º 2
0
def test_get_poetry_linecount():
    r = get_poetry('linecount', '51', 'author,linecount,title')

    assert isinstance(r, list)
    assert r[0]['author'] == 'Edward Thomas'
    assert r[1]['author'] == 'John Clare'
    assert r[2]['author'] == 'Percy Bysshe Shelley'

    assert r[0]['linecount'] == r[1]['linecount'] == r[2]['linecount']
Exemplo n.º 3
0
def test_get_poetry_author():
    r1 = get_poetry('author', 'Ernest Dowson', 'author,title,linecount')

    r2 = get_poetry('author',
                    'Ernest Dowson',
                    'author,title,linecount',
                    search_type='abs')

    assert isinstance(r1, list)
    assert isinstance(r1[0], dict)

    assert r1 == r2

    r3 = get_poetry('author',
                    'Ernest Dowson',
                    'author,title,linecount',
                    output_format='text')

    assert isinstance(r3, str)
Exemplo n.º 4
0
        elif 'close vlc' in query:
            os.system("TASKKILL /F /IM vlc.exe")

        elif 'close spotify' in query:
            os.system("TASKKILL /F /IM Spotify.exe")

        elif 'price of' in query:
            query = query.replace('price of', '')
            query = "https://www.amazon.in/s?k=" + query[
                -1]  #indexing since I only want the keyword
            webbrowser.open(query)

        elif 'poem' in query:
            fun_talk('Poem of which author you want to listen?')
            auth = get_command()
            poem = poetpy.get_poetry('author', auth, 'title,linecount')
            poems = poetpy.get_poetry('author', auth, 'lines')

            poem_len = len(poem)
            # print(poem_len)
            poem_no = random.randint(1, poem_len)
            print("Title- ", poem[poem_no]['title'])
            fun_talk(f"Title- {poem[poem_no]['title']}")
            print("No. of lines-", poem[poem_no]['linecount'])
            fun_talk(f"No. of lines- {poem[poem_no]['linecount']}")
            poem_str = '\n'
            print("Poem-\n", poem_str.join(poems[poem_no]['lines']))
            fun_talk(f"Poem-\n {poem_str.join(poems[poem_no]['lines'])}")

        elif 'resume' in query or 'pause' in query:
            pyautogui.press("playpause")
Exemplo n.º 5
0
def test_poetry_exceptions():
    with pytest.raises(ValueError):
        r = get_poetry('author', output_format='lfhdsubg')
Exemplo n.º 6
0
def test_get_poetry_combination():
    r = get_poetry('author,title', 'William Shakespeare;Spring and Winter ii',
                   'author,title')

    assert r[0]['author'] == 'William Shakespeare'
    assert r[0]['title'] == 'Spring and Winter ii'
Exemplo n.º 7
0
def test_get_poetry_lines():
    r = get_poetry('lines', 'Latitudeless Place', 'author,title,linecount')

    assert r[0]['author'] == 'Emily Dickinson'
    assert int(r[0]['linecount']) == 20
    assert r[0]['title'] == 'Now I knew I lost her --'