Exemplo n.º 1
0
    def testSearch(self):
        """Test searching by name prefix."""
        # Defined out of order to make sure search is in order.
        model.ArtistInfo(name='The  Bee__Gees').put()
        model.ArtistInfo(name='  The-DooRs  ').put()
        model.ArtistInfo(name='Wendy Carlos').put()
        model.ArtistInfo(name='Amadeus Mozart').put()
        model.ArtistInfo(name='The Beatles').put()

        names = [artist.name for artist in model.ArtistInfo.search('  ')]
        self.assertEquals([
            'Amadeus Mozart', 'The Beatles', 'The  Bee__Gees', '  The-DooRs  ',
            'Wendy Carlos'
        ], names)

        names = [
            artist.name for artist in model.ArtistInfo.search('  !tHe}  ')
        ]
        self.assertEquals(['The Beatles', 'The  Bee__Gees', '  The-DooRs  '],
                          names)

        names = [
            artist.name for artist in model.ArtistInfo.search('the bee gees')
        ]
        self.assertEquals(['The  Bee__Gees'], names)

        names = [
            artist.name for artist in model.ArtistInfo.search('the  doors')
        ]
        self.assertEquals(['  The-DooRs  '], names)
Exemplo n.º 2
0
        def get_encoded_name(name):
            """Helper to get encoded name for an provided name.

      Args:
        name: Encoded name to convert to encoded_name.
      """
            return db.get(model.ArtistInfo(name=name).put()).encoded_name
Exemplo n.º 3
0
    def setUp(self):
        """Set up music library."""
        super(MusicLibraryServiceTest, self).setUp()

        self.service = tunes_db.MusicLibraryService()

        # Create a bunch of artists.
        #
        # Definitions are not defined in order to test that search order is
        # correct.
        self.aem = model.ArtistInfo(name='Amadou et Miriam')
        self.aem.put()

        self.abba = model.ArtistInfo(name='Abba')
        self.abba.put()

        self.furnaces = model.ArtistInfo(name='The Fiery Furnaces')
        self.furnaces.put()

        self.go_team = model.ArtistInfo(name='  The Go! Team  ')
        self.go_team.put()

        self.wendy_carlos = model.ArtistInfo(name='Wendy Carlos')
        self.wendy_carlos.put()

        self.beatles = model.ArtistInfo(name='The Beatles')
        self.beatles.put()

        # Albums.

        # The Go! Team.
        self.get_it_together = model.AlbumInfo(name='Get It Together',
                                               released=2000,
                                               artist=self.go_team,
                                               parent=self.go_team)
        self.get_it_together.put()

        self.thunder_lightening_strike = model.AlbumInfo(
            name='Thunder, Lightning, Strike',
            released=2004,
            artist=self.go_team,
            parent=self.go_team)
        self.thunder_lightening_strike.put()

        self.proof_of_youth = model.AlbumInfo(name='Proof of Youth',
                                              released=2007,
                                              artist=self.go_team,
                                              parent=self.go_team)
        self.proof_of_youth.put()

        # The Beatles.
        self.help = model.AlbumInfo(name='Help',
                                    released=1965,
                                    artist=self.beatles,
                                    parent=self.beatles)
        self.help.put()

        self.yellow_submarine = model.AlbumInfo(name='Yellow Submarine',
                                                released=1969,
                                                artist=self.beatles,
                                                parent=self.beatles)
        self.yellow_submarine.put()
Exemplo n.º 4
0
 def do_add():
   artist = model.ArtistInfo(name=artist_name)
   artist.put()
   return artist