def test_that_check_song_returns_true(self, check_instrumental, mock_get,
                                          mock_response, spotify_token):
        from swaglyrics_backend.issue_maker import check_song
        mock_response.return_value = get_correct_spotify_search_json(
            'correct_spotify_data.json')

        self.assertTrue(check_song("Miracle", "Caravan Palace"))
 def test_check_song_returns_false_on_bad_response(self, requests_mock,
                                                   response_mock,
                                                   spotify_mock):
     from swaglyrics_backend.issue_maker import check_song
     from swaglyrics_backend import issue_maker
     issue_maker.t_expiry = time.time() + 3600
     self.assertFalse(check_song("Miracle", "Caravan Palace"))
    def test_that_check_song_returns_false_when_mismatch(
            self, mock_get, spotify_token):
        from swaglyrics_backend.issue_maker import check_song
        wrong_json = get_spotify_json('correct_spotify_data.json')
        wrong_json['tracks']['items'][0][
            'name'] = "Not Miracle"  # so it mismatches
        mock_get.return_value.json.return_value = wrong_json

        assert not check_song("Miracle", "Caravan Palace")
    def test_that_check_song_returns_false_when_instrumental(
            self, check_instrumental, mock_get, spotify_token):
        from swaglyrics_backend.issue_maker import check_song
        mock_get.return_value.json.return_value = get_spotify_json(
            'correct_spotify_data.json')

        with self.assertLogs() as logs:
            resp = check_song("Miracle", "Caravan Palace")

        assert not resp
        assert "Miracle by Caravan Palace seems to be instrumental" in logs.output[
            2]
 def test_that_check_song_returns_false_on_non_legit_song(
         self, mock_get, mock_response, spotify_token):
     from swaglyrics_backend.issue_maker import check_song
     self.assertFalse(check_song("Miracle", "Caravan Palace"))