예제 #1
0
    def test_get_cached_songs(self):
        ''' When lyrics exists in DB'''
        self._create()
        fac = Factory()

        db_lyrics = fac.getCachedSongs()

        self.assertEqual(len(db_lyrics), 1)
예제 #2
0
    def test_get_cached_songs(self):
        ''' When lyrics exists in DB'''
        self._create()
        fac = Factory()

        db_lyrics = fac.getCachedSongs()

        self.assertEqual(len(db_lyrics), 1)
예제 #3
0
    def test_get_lyrics_raises(self):
        fac = Factory()

        with self.assertRaises(ArtistNotFound):
            fac.getLyrics(artist='Pear', music='Last Kiss')

        with self.assertRaises(ArtistNotFound):
            fac.getLyrics(artist='Pear Jam', music='Last')
예제 #4
0
    def test_get_lyrics_without_db(self):
        ''' When lyrics does not exist in DB '''
        fac = Factory()

        db_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        self.assertIsInstance(db_lyrics, Lyrics)
        self.assertEqual(str(db_lyrics), 'Pearl Jam - Last Kiss')
예제 #5
0
    def test_get_lyrics_without_db(self):
        ''' When lyrics does not exist in DB '''
        fac = Factory()

        db_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        self.assertIsInstance(db_lyrics, Lyrics)
        self.assertEqual(str(db_lyrics), 'Pearl Jam - Last Kiss')
예제 #6
0
    def test_get_lyrics_with_db(self):
        ''' When lyrics exists in DB'''
        self._create()

        fac = Factory()

        db_lyrics = fac.getLyrics(artist='Testudo', music='Test')

        self.assertIsInstance(db_lyrics, Lyrics)
        self.assertEqual(str(db_lyrics), 'Testudo - Test')
예제 #7
0
    def test_get_lyrics_with_db(self):
        ''' When lyrics exists in DB'''
        self._create()

        fac = Factory()

        db_lyrics = fac.getLyrics(artist='Testudo', music='Test')

        self.assertIsInstance(db_lyrics, Lyrics)
        self.assertEqual(str(db_lyrics), 'Testudo - Test')
예제 #8
0
    def test_get_expired_lyrics(self):
        ''' When lyrics exists and is expired '''
        fac = Factory()
        old_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        new_date = datetime.strptime('2014-04-04', '%Y-%m-%d')
        old_lyrics.created_date = new_date

        old_lyrics.save()

        new_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        expected = datetime.now().date()
        self.assertEqual(new_lyrics.created_date, expected)
예제 #9
0
    def test_get_expired_lyrics(self):
        ''' When lyrics exists and is expired '''
        fac = Factory()
        old_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        new_date = datetime.strptime('2014-04-04', '%Y-%m-%d')
        old_lyrics.created_date = new_date

        old_lyrics.save()

        new_lyrics = fac.getLyrics(artist='Pearl Jam', music='Last Kiss')

        expected = datetime.now().date()
        self.assertEqual(new_lyrics.created_date, expected)
예제 #10
0
    def test_get_lyrics_raises(self):
        fac = Factory()

        with self.assertRaises(ArtistNotFound):
            fac.getLyrics(artist='Pear', music='Last Kiss')

        with self.assertRaises(ArtistNotFound):
            fac.getLyrics(artist='Pear Jam', music='Last')