Skip to content
Permalink
Browse files

Added update test (#24)

* Added CL/CV and one test

* Removed not supported python versions

* Added codecov to setup

* Small travis update

* Another small travis update

Added pip3 install codecov

* Hopefully final travis changes

* Changed test script path

* Removed placeholder test

* Updated test enviroment

* Added username env variable to test enviroment

* Wrote 4 tests

* Fixed one test

* Wrote 5 more tests

* Changed update token on init statement

* Resloved utils

* merge conflict solve wip

* Merge conflict fix

* Wrote a lot of tests

* Changed patching enviroment variables in tests

* Removed fake unsupported from tests

* Removed unused import

* WIP merge conflict

* Merge conflict resolved

* Small fixes

* Changed test parameter from set to list

* Added update test

* updated visuals

* Updated code style

* Updated code style, now from Pycharm
  • Loading branch information
flabbet committed Feb 2, 2020
1 parent fd5b577 commit e88d5547b554f790b126880239e01ae1f855025b
Showing with 32 additions and 4 deletions.
  1. +32 −4 tests/test_issue_maker.py
@@ -75,7 +75,8 @@ def test_check_song_returns_false_on_bad_response(self, requests_mock, response_
@patch('requests.get', return_value=Response())
def test_that_check_song_returns_true(self, 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')
mock_response.return_value = get_correct_spotify_search_json(
'correct_spotify_data.json')
self.assertTrue(check_song("Miracle", "Caravan Palace"))

@patch('swaglyrics_backend.issue_maker.get_spotify_token', return_value={"access_token": ""})
@@ -97,9 +98,11 @@ def test_that_stripper_returns_stripper(self, mock_get, mock_response):
response = Response()
response.status_code = 200
mock_get.return_value = response
mock_response.return_value = get_correct_spotify_search_json('sample_genius_data.json')
mock_response.return_value = get_correct_spotify_search_json(
'sample_genius_data.json')
from swaglyrics_backend.issue_maker import genius_stripper
self.assertEqual(genius_stripper("Miracle", "Caravan Palace"), "Caravan-palace-miracle")
self.assertEqual(genius_stripper(
"Miracle", "Caravan Palace"), "Caravan-palace-miracle")

def test_that_title_mismatches(self):
from swaglyrics_backend.issue_maker import is_title_mismatched
@@ -152,6 +155,31 @@ def test_that_delete_line_deletes_line_from_master_unsupported(self):
self.assertEqual(response, "Removed 1 instances of Supersonics by Caravan Palace from "
"unsupported.txt successfully.")

def test_update(self):
from swaglyrics import __version__
from swaglyrics_backend.issue_maker import update
from flask import Flask

app = Flask(__name__)
with app.test_request_context('/'):
with app.test_client() as c:
app.config['TESTING'] = True

c.post('/unsupported', data={'version': '0.9.0',
'song': 'Miracle',
'artist': 'Caravan Palace'})
generate_fake_unsupported()
self.assertEqual(
update(), 'Please update SwagLyrics to the latest version to get better support :)')

c.post('/unsupported', data={'version': str(__version__),
'song': 'Miracle',
'artist': 'Caravan Palace'})
"""Test correct output given song and artist that exist in unsupported.txt"""
self.assertEqual(update(),
"Issue already exists on the GitHub repo. "
"\nhttps://github.com/SwagLyrics/SwagLyrics-For-Spotify/issues")


def get_correct_spotify_search_json(filename):
import flask
@@ -162,4 +190,4 @@ def get_correct_spotify_search_json(filename):

def generate_fake_unsupported():
with open('unsupported.txt', 'w') as f:
f.write('Miracle by Caravan Palace\n' + 'Supersonics by Caravan Palace\n')
f.write('Miracle by Caravan Palace\nSupersonics by Caravan Palace\n')

0 comments on commit e88d554

Please sign in to comment.
You can’t perform that action at this time.