Пример #1
0
 def test_multiple_mixed_artists(self):
     mixed_artist_responses = [{
         'response': {
             'status': {
                 'code': 5,
                 'message': 'The Identifier specified does not exist',
                 'version': '4.2'
             }
         }
     }, {
         'response': {
             'status': {
                 'code': 0,
                 'message': 'Success',
                 'version': '4.2'
             },
             'artist': {
                 'familiarity': 0.908821,
                 'hotttnesss': 0.804396,
                 'name': 'The Beatles',
                 'id': 'AR6XZ861187FB4CECD'
             }
         }
     }]
     self.assertEqual(main.format_artist_profiles(mixed_artist_responses),
                      [{
                          'familiarity': 0.908821,
                          'hotttnesss': 0.804396,
                          'name': 'The Beatles',
                          'id': 'AR6XZ861187FB4CECD'
                      }])
Пример #2
0
 def test_single_invalid_artist(self):
     invalid_artist_response = [{
         'response': {
             'status': {
                 'code': 5,
                 'message': 'The Identifier specified does not exist',
                 'version': '4.2'
             }
         }
     }]
     self.assertEqual(main.format_artist_profiles(invalid_artist_response),
                      [])
Пример #3
0
 def test_multiple_valid_artists(self):
     valid_artist_responses = [{
         'response': {
             'status': {
                 'code': 0,
                 'message': 'Success',
                 'version': '4.2'
             },
             'artist': {
                 'familiarity': 0.908821,
                 'hotttnesss': 0.804396,
                 'name': 'The Beatles',
                 'id': 'AR6XZ861187FB4CECD'
             }
         }
     }, {
         'response': {
             'status': {
                 'code': 0,
                 'message': 'Success',
                 'version': '4.2'
             },
             'artist': {
                 'familiarity': 0.858889,
                 'hotttnesss': 0.797314,
                 'name': 'Pink Floyd',
                 'id': 'ARD4C1I1187FB4B0C3'
             }
         }
     }]
     self.assertEqual(main.format_artist_profiles(valid_artist_responses),
                      [{
                          'familiarity': 0.908821,
                          'hotttnesss': 0.804396,
                          'name': 'The Beatles',
                          'id': 'AR6XZ861187FB4CECD'
                      }, {
                          'familiarity': 0.858889,
                          'hotttnesss': 0.797314,
                          'name': 'Pink Floyd',
                          'id': 'ARD4C1I1187FB4B0C3'
                      }])
Пример #4
0
 def test_single_valid_artist(self):
     valid_artist_response = [{
         'response': {
             'status': {
                 'code': 0,
                 'message': 'Success',
                 'version': '4.2'
             },
             'artist': {
                 'familiarity': 0.908821,
                 'hotttnesss': 0.804396,
                 'name': 'The Beatles',
                 'id': 'AR6XZ861187FB4CECD'
             }
         }
     }]
     self.assertEqual(main.format_artist_profiles(valid_artist_response),
                      [{
                          'familiarity': 0.908821,
                          'hotttnesss': 0.804396,
                          'name': 'The Beatles',
                          'id': 'AR6XZ861187FB4CECD'
                      }])
Пример #5
0
 def test_no_artists(self):
     self.assertEqual(main.format_artist_profiles([]), [])
Пример #6
0
 def test_single_valid_artist(self):
     valid_artist_response = [{'response': {'status': {'code': 0, 'message': 'Success', 'version': '4.2'}, 'artist': {'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}}}]
     self.assertEqual(main.format_artist_profiles(valid_artist_response),
                      [{'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}])
Пример #7
0
 def test_no_artists(self):
     self.assertEqual(main.format_artist_profiles([]), [])
Пример #8
0
 def test_multiple_mixed_artists(self):
     mixed_artist_responses = [{'response': {'status': {'code': 5, 'message': 'The Identifier specified does not exist', 'version': '4.2'}}},
                               {'response': {'status': {'code': 0, 'message': 'Success', 'version': '4.2'}, 'artist': {'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}}}]
     self.assertEqual(main.format_artist_profiles(mixed_artist_responses),
                      [{'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}])
Пример #9
0
 def test_multiple_invalid_artists(self):
     invalid_artist_responses = [{'response': {'status': {'code': 5, 'message': 'The Identifier specified does not exist', 'version': '4.2'}}},
                                 {'response': {'status': {'code': 5, 'message': 'The Identifier specified does not exist', 'version': '4.2'}}}]
     self.assertEqual(main.format_artist_profiles(invalid_artist_responses), [])
Пример #10
0
 def test_multiple_valid_artists(self):
     valid_artist_responses = [{'response': {'status': {'code': 0, 'message': 'Success', 'version': '4.2'}, 'artist': {'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}}},
                               {'response': {'status': {'code': 0, 'message': 'Success', 'version': '4.2'}, 'artist': {'familiarity': 0.858889, 'hotttnesss': 0.797314, 'name': 'Pink Floyd', 'id': 'ARD4C1I1187FB4B0C3'}}}]
     self.assertEqual(main.format_artist_profiles(valid_artist_responses),
                      [{'familiarity': 0.908821, 'hotttnesss': 0.804396, 'name': 'The Beatles', 'id': 'AR6XZ861187FB4CECD'}, {'familiarity': 0.858889, 'hotttnesss': 0.797314, 'name': 'Pink Floyd', 'id': 'ARD4C1I1187FB4B0C3'}])