Exemple #1
0
 def test_request_simple(self, mock_method):
     BlitzrClient(API_KEY)._request(method='/blitzr_method')
     mock_method.assert_called_once_with(
         url=BlitzrClient.BASE_URL % '/blitzr_method',
         params={
             'key'   : API_KEY
         }
     )
Exemple #2
0
 def test_request_with_params(self, mock_method):
     BlitzrClient(API_KEY)._request(method='/blitzr_method', params={'toto': 'toto'})
     mock_method.assert_called_once_with(
         url=BlitzrClient.BASE_URL % '/blitzr_method',
         params={
             'key'   : API_KEY,
             'toto'  : 'toto'
         }
     )
Exemple #3
0
 def test_get_artist_by_uuid(self, mock_method):
     BlitzrClient(API_KEY).get_artist(uuid='AR89798789798787')
     mock_method.assert_called_once_with(
         url=BlitzrClient.BASE_URL % '/artist/',
         params={
             'key'           : API_KEY,
             'slug'          : None,
             'uuid'          : 'AR89798789798787',
             'extras'        : None,
             'extras_limit'  : None
         })
Exemple #4
0
def post_detail(request, pk):
    post = get_object_or_404(Post, pk=pk)

    blitzr = BlitzrClient('42b3a88e99f4c3545d713b3824544370')
    artist = post.title
    artists = blitzr.search_artist(query=artist, autocomplete=True)

    artist_uuid = artists['results'][0]['uuid']
    print(artist_uuid)

    artists1 = blitzr.get_artist_similar(slug=artist)
    print(artists1)
    artists_list = []
    for items in range(0, 5):
        artists_list.append(artists1[items]['name'])
    print(artists_list)
    post.artist1 = artists_list[0]
    post.artist2 = artists_list[1]
    post.artist3 = artists_list[2]
    post.artist4 = artists_list[3]
    post.artist5 = artists_list[4]

    return render(request, 'blog/post_detail.html', {'post': post})
Exemple #5
0
 def test_get_artist_aliases_by_slug(self, mock_method):
     BlitzrClient(API_KEY).get_artist_aliases(slug='toto')
     mock_method.assert_called_once_with(url=BlitzrClient.BASE_URL % '/artist/aliases/', params={'key': API_KEY, 'slug':'toto', 'uuid':None})