def test_search_results_are_truncated(self):
        # Make sure that the max_num_results works properly.
        matches = search.simple_music_search(u"beat*", max_num_results=2,
                                             entity_kind='Artist')
        self.assertEquals(len(matches['Artist']), 2)

        # Now revoke one of the two matches
        revoked_art = matches['Artist'].pop()
        revoked_art.revoked = True
        revoked_art.save()

        # Now perform the same query again: we should get two results,
        # specifically the two items we didn't revoke.
        new_matches = search.simple_music_search(u"beat*", max_num_results=2,
                                                 entity_kind='Artist')
        self.assertEquals(len(new_matches['Artist']), 2)
        self.assertTrue(new_matches['Artist'][0].key() != revoked_art.key())
        self.assertTrue(new_matches['Artist'][1].key() != revoked_art.key())

        # Now revoke one more item and repeat the query.  The lone
        # unrevoked item should be the only result.
        new_matches["Artist"][0].revoked = True
        new_matches["Artist"][0].save()
        unrevoked_art = new_matches["Artist"][1]
        newer_matches = search.simple_music_search(u"beat*", max_num_results=2,
                                                   entity_kind='Artist')
        self.assertEquals(len(newer_matches['Artist']), 1)
        self.assertEquals(newer_matches['Artist'][0].key(),
                          unrevoked_art.key())
Beispiel #2
0
    def test_search_results_are_truncated(self):
        # Make sure that the max_num_results works properly.
        matches = search.simple_music_search(u"beat*",
                                             max_num_results=2,
                                             entity_kind='Artist')
        self.assertEquals(len(matches['Artist']), 2)

        # Now revoke one of the two matches
        revoked_art = matches['Artist'].pop()
        revoked_art.revoked = True
        revoked_art.save()

        # Now perform the same query again: we should get two results,
        # specifically the two items we didn't revoke.
        new_matches = search.simple_music_search(u"beat*",
                                                 max_num_results=2,
                                                 entity_kind='Artist')
        self.assertEquals(len(new_matches['Artist']), 2)
        self.assertTrue(new_matches['Artist'][0].key() != revoked_art.key())
        self.assertTrue(new_matches['Artist'][1].key() != revoked_art.key())

        # Now revoke one more item and repeat the query.  The lone
        # unrevoked item should be the only result.
        new_matches["Artist"][0].revoked = True
        new_matches["Artist"][0].save()
        unrevoked_art = new_matches["Artist"][1]
        newer_matches = search.simple_music_search(u"beat*",
                                                   max_num_results=2,
                                                   entity_kind='Artist')
        self.assertEquals(len(newer_matches['Artist']), 1)
        self.assertEquals(newer_matches['Artist'][0].key(),
                          unrevoked_art.key())
Beispiel #3
0
    def test_search_tags(self):
        # No tag.
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(len(matches), 0)

        # Add a tag.
        tag_util.add_tag_and_save(self.user, self.album, u"Electro")
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(matches['Album'][0].title, 'test album')

        # Remove a tag.
        tag_util.remove_tag_and_save(self.user, self.album, u"Electro")
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(len(matches), 0)
    def test_search_tags(self):
        # No tag.
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(len(matches), 0)
        
        # Add a tag.
        tag_util.add_tag_and_save(self.user, self.album, u"Electro")
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(matches['Album'][0].title, 'test album')

        # Remove a tag.
        tag_util.remove_tag_and_save(self.user, self.album, u"Electro")
        matches = search.simple_music_search(u"tag:Electro")
        self.assertEqual(len(matches), 0)