MCPcopy
hub / github.com/beetbox/beets / test_track_request

Method test_track_request

test/plugins/test_spotify.py:92–124  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

90
91 @responses.activate
92 def test_track_request(self):
93 json_file = os.path.join(
94 _common.RSRC, b"spotify", b"track_request.json"
95 )
96 with open(json_file, "rb") as f:
97 response_body = f.read()
98
99 responses.add(
100 responses.GET,
101 spotify.SpotifyPlugin.search_url,
102 body=response_body,
103 status=200,
104 content_type="application/json",
105 )
106 item = Item(
107 mb_trackid="01234",
108 album="Despicable Me 2",
109 albumartist="Pharrell Williams",
110 title="Happy",
111 length=10,
112 )
113 item.add(self.lib)
114 results = self.spotify._match_library_tracks(self.lib, "Happy")
115 assert 1 == len(results)
116 assert "6NPVjNh8Jhru9xOmyQigds" == results[0]["id"]
117 self.spotify._output_match_results(results)
118
119 params = _params(responses.calls[0].request.url)
120 query = params["q"][0]
121 assert "Happy" in query
122 assert "artist:'Pharrell Williams'" in query
123 assert "album:'Despicable Me 2'" in query
124 assert params["type"] == ["track"]
125
126 @responses.activate
127 def test_track_for_id(self):

Callers

nothing calls this directly

Calls 7

ItemClass · 0.90
_paramsFunction · 0.85
joinMethod · 0.80
_match_library_tracksMethod · 0.80
_output_match_resultsMethod · 0.80
readMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected