Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CL/CV Support and tests #19

Merged
merged 27 commits into from Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2724007
Added CL/CV and one test
flabbet Jan 22, 2020
af7c813
Removed not supported python versions
flabbet Jan 22, 2020
a47ec1c
Added codecov to setup
flabbet Jan 22, 2020
4584346
Small travis update
flabbet Jan 22, 2020
9df4dc2
Another small travis update
flabbet Jan 22, 2020
296160f
Hopefully final travis changes
flabbet Jan 22, 2020
01cd605
Changed test script path
flabbet Jan 22, 2020
2e62c5a
Removed placeholder test
flabbet Jan 22, 2020
29d505f
Updated test enviroment
flabbet Jan 22, 2020
2298966
Added username env variable to test enviroment
flabbet Jan 22, 2020
9a332b4
Wrote 4 tests
flabbet Jan 22, 2020
c719f17
Fixed one test
flabbet Jan 22, 2020
e4ccfeb
Wrote 5 more tests
flabbet Jan 23, 2020
02d0cb5
Changed update token on init statement
flabbet Jan 23, 2020
f4d8717
Resloved utils
flabbet Jan 23, 2020
287d231
merge conflict solve wip
flabbet Jan 23, 2020
17f263c
Merge remote-tracking branch 'SwagLyrics/master'
flabbet Jan 23, 2020
9e3f74d
Merge conflict fix
flabbet Jan 23, 2020
71d9276
Wrote a lot of tests
flabbet Jan 24, 2020
d1aebae
Changed patching enviroment variables in tests
flabbet Jan 25, 2020
fe1347f
Removed fake unsupported from tests
flabbet Jan 25, 2020
433c3c0
Removed unused import
flabbet Jan 25, 2020
081a7b6
WIP merge conflict
flabbet Jan 27, 2020
dfe528e
Merge remote-tracking branch 'SwagLyrics/master'
flabbet Jan 27, 2020
3058068
Merge conflict resolved
flabbet Jan 27, 2020
3587f00
Small fixes
flabbet Jan 27, 2020
7c82795
Changed test parameter from set to list
flabbet Jan 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .coveragerc
@@ -0,0 +1,14 @@
[run]
branch = True
source = swaglyrics-backend

[report]
exclude_lines =
if self.debug:
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
ignore_errors = True
omit =
tests/*
setup.py
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,8 @@
__pycache__/
.env
/unsupported.txt
venv/

.coverage

swaglyrics_backend.egg-info/
11 changes: 11 additions & 0 deletions .travis.yml
@@ -0,0 +1,11 @@
language: python
python:
- "3.8"
- "3.8-dev"
- "nightly"
install:
- pip3 install -r requirements.txt
- pip3 install -e .[dev]
script:
- pytest --cov-config=.coveragerc --cov=swaglyrics_backend tests/
- codecov
26 changes: 26 additions & 0 deletions setup.py
@@ -0,0 +1,26 @@
import setuptools

import swaglyrics_backend

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="swaglyrics_backend",
version=swaglyrics_backend.__version__,
author="Aadi Bajpai",
description="Server side code to communicate with SwagLyrics, manage unsupported songs and make an issue on the "
"main repo when the program encounters a song it can't fetch lyrics for.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/SwagLyrics/swaglyrics-backend",
packages=['swaglyrics_backend'],
install_requires=['flask', 'Flask-Limiter', 'GitPython', 'flask_sqlalchemy', 'swaglyrics', 'requests'],
extras_require={
'dev': [
'pytest',
'pytest-cov',
'codecov'
]
},
)
1 change: 1 addition & 0 deletions swaglyrics_backend/__init__.py
@@ -0,0 +1 @@
__version__ = "0.0.1"
32 changes: 17 additions & 15 deletions issue_maker.py → swaglyrics_backend/issue_maker.py
Expand Up @@ -13,7 +13,7 @@
from swaglyrics import __version__
from swaglyrics.cli import stripper

from utils import request_from_github, validate_request, get_jwt, get_installation_access_token
from swaglyrics_backend.utils import request_from_github, validate_request, get_jwt, get_installation_access_token

# start flask app
app = Flask(__name__)
Expand Down Expand Up @@ -53,10 +53,9 @@

SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://{username}:{password}@{username}.mysql.pythonanywhere-services." \
"com/{username}${databasename}".format(
username=username,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this maybe? formatting changes interfere with reviewing the main code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still slightly different :P

password=os.environ['DB_PWD'],
databasename="strippers",
)
username=username,
password=os.environ['DB_PWD'],
databasename="strippers")
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_POOL_RECYCLE"] = 280
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
Expand Down Expand Up @@ -146,8 +145,8 @@ def genius_stripper(song, artist):
print(f'stripped title: {title}')

words = title.split()

max_err = len(words) // 2

# allow half length mismatch
print(f'max_err is set to {max_err}')

Expand All @@ -162,15 +161,7 @@ def genius_stripper(song, artist):
full_title = re.sub(alg, '', full_title)
print(f'stripped full title: {full_title}')

err_cnt = 0

for word in words:
if word.lower() not in full_title.lower():
err_cnt += 1
print(f'broke on {word}')
if err_cnt > max_err:
break
else:
if not is_title_mismatched(words, full_title, max_err):
# return stripper as no mismatch
path = gstr.search(hit['result']['path'])
try:
Expand All @@ -184,6 +175,17 @@ def genius_stripper(song, artist):
return None


def is_title_mismatched(words, full_title, max_err):
err_cnt = 0
for word in words:
if word.lower() not in full_title.lower():
err_cnt += 1
print(f'broke on {word}')
if err_cnt > max_err:
return True
return False


def create_issue(song, artist, version, stripper='not supported yet'):
"""
Create an issue on the SwagLyrics for Spotify repo when a song, artist pair is not supported.
Expand Down
File renamed without changes.
File renamed without changes.