Added flake to drone.yaml
Changes proposed by flake
This commit is contained in:
parent
5cb36d7f34
commit
2eb62a790f
|
@ -3,14 +3,15 @@ pipeline:
|
||||||
image: python
|
image: python
|
||||||
commands:
|
commands:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
|
- pip install flake8
|
||||||
- python3 test_tmdb.py
|
- python3 test_tmdb.py
|
||||||
|
- flake8 --ignore=E501
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: alpine
|
image: alpine
|
||||||
commands:
|
commands:
|
||||||
- apk add zip
|
- apk add zip
|
||||||
- ./create_release.sh ${DRONE_COMMIT_SHA:0:8}
|
- ./create_release.sh ${DRONE_COMMIT_SHA:0:8}
|
||||||
- ls *.mbp
|
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
image: uploader
|
image: uploader
|
||||||
|
|
11
test_tmdb.py
11
test_tmdb.py
|
@ -7,7 +7,7 @@ from sqlalchemy import create_engine
|
||||||
|
|
||||||
|
|
||||||
class TestTmdbMethods(unittest.TestCase):
|
class TestTmdbMethods(unittest.TestCase):
|
||||||
### TMDB API
|
# TMDB API
|
||||||
def test_search_item(self):
|
def test_search_item(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
id = movie.search_title('Breakfast Club')
|
id = movie.search_title('Breakfast Club')
|
||||||
|
@ -16,7 +16,7 @@ class TestTmdbMethods(unittest.TestCase):
|
||||||
def test_cast(self):
|
def test_cast(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
movie.search_title('Breakfast Club')
|
movie.search_title('Breakfast Club')
|
||||||
self.assertEqual('Anthony Michael Hall', movie.cast[0])
|
self.assertEqual('Emilio Estevez', movie.cast[0])
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
|
@ -38,7 +38,6 @@ class TestTmdbMethods(unittest.TestCase):
|
||||||
|
|
||||||
def test_html_construction(self):
|
def test_html_construction(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
tmdb = TmdbBot("","" ,"" ,"" ,"" ,"" ,"" ,"" ,"" )
|
|
||||||
movie.query_details('550')
|
movie.query_details('550')
|
||||||
constructor = MessageConstructor(movie)
|
constructor = MessageConstructor(movie)
|
||||||
constructor.overview_length = 10
|
constructor.overview_length = 10
|
||||||
|
@ -102,16 +101,16 @@ class TestTmdbMethods(unittest.TestCase):
|
||||||
movie.search_title('The Flash')
|
movie.search_title('The Flash')
|
||||||
self.assertEqual('The Flash', movie.title)
|
self.assertEqual('The Flash', movie.title)
|
||||||
|
|
||||||
def test_cast(self):
|
def test_cast_2(self):
|
||||||
movie = TvShow()
|
movie = TvShow()
|
||||||
movie.search_title('The Flash')
|
movie.search_title('The Flash')
|
||||||
#self.assertEqual('Tom Cavanagh', movie.cast[0])
|
|
||||||
self.assertEqual('Danielle Panabaker', movie.cast[2])
|
self.assertEqual('Danielle Panabaker', movie.cast[2])
|
||||||
|
|
||||||
def test_poster_path(self):
|
def test_poster_path(self):
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
id = movie.search_title('Dune')
|
movie.search_title('Dune')
|
||||||
self.assertEqual(movie.poster_url, "http://image.tmdb.org/t/p/w92/9HNZTw2D3cM1yA08FF5SeWEO9eX.jpg")
|
self.assertEqual(movie.poster_url, "http://image.tmdb.org/t/p/w92/9HNZTw2D3cM1yA08FF5SeWEO9eX.jpg")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
from .tmdb import TmdbBot
|
|
|
@ -14,16 +14,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||||
along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from sqlalchemy import (Column, String, Integer, ForeignKey, Table, MetaData,
|
from sqlalchemy import (Column, String, Integer, Table, MetaData, select)
|
||||||
select, and_)
|
|
||||||
from sqlalchemy.engine.base import Engine
|
from sqlalchemy.engine.base import Engine
|
||||||
|
|
||||||
|
|
||||||
class Database:
|
class Database:
|
||||||
db: Engine
|
db: Engine
|
||||||
|
|
||||||
def __init__(self, db: Engine) -> None:
|
def __init__(self, db: Engine) -> None:
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
meta = MetaData()
|
meta = MetaData()
|
||||||
meta.bind = db
|
meta.bind = db
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ from maubot.handlers import command
|
||||||
from tmdb.tmdb_api import TmdbApi, Movie, TvShow
|
from tmdb.tmdb_api import TmdbApi, Movie, TvShow
|
||||||
from tmdb.database import Database
|
from tmdb.database import Database
|
||||||
|
|
||||||
|
|
||||||
class MessageConstructor():
|
class MessageConstructor():
|
||||||
def __init__(self, movie: TmdbApi):
|
def __init__(self, movie: TmdbApi):
|
||||||
self.movie = movie
|
self.movie = movie
|
||||||
|
@ -42,7 +43,6 @@ class MessageConstructor():
|
||||||
cast += f'{actor}, '
|
cast += f'{actor}, '
|
||||||
return cast[:-2]
|
return cast[:-2]
|
||||||
|
|
||||||
|
|
||||||
def construct_html_message(self) -> str:
|
def construct_html_message(self) -> str:
|
||||||
html_message = f"""<p><a href="{self.movie.web_url}"><b>{escape(self.movie.title)}</b></a></p>
|
html_message = f"""<p><a href="{self.movie.web_url}"><b>{escape(self.movie.title)}</b></a></p>
|
||||||
<p>{escape(self.movie.overview)[:self.overview_length]}{self.three_dotts()}</p>
|
<p>{escape(self.movie.overview)[:self.overview_length]}{self.three_dotts()}</p>
|
||||||
|
|
|
@ -15,6 +15,7 @@ along with tmdb-bot. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class TmdbApi():
|
class TmdbApi():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.load_parameters()
|
self.load_parameters()
|
||||||
|
@ -30,7 +31,6 @@ class TmdbApi():
|
||||||
|
|
||||||
def load_parameters(self):
|
def load_parameters(self):
|
||||||
self.api_key = '51d75c00dc1502dc894b7773ec3e7a15'
|
self.api_key = '51d75c00dc1502dc894b7773ec3e7a15'
|
||||||
|
|
||||||
self.base_url = "https://api.themoviedb.org/3/"
|
self.base_url = "https://api.themoviedb.org/3/"
|
||||||
result = requests.get(self.base_url + 'configuration', params=self.get_apikey()).json()
|
result = requests.get(self.base_url + 'configuration', params=self.get_apikey()).json()
|
||||||
self.base_url_images = result['images']['base_url']
|
self.base_url_images = result['images']['base_url']
|
||||||
|
|
Loading…
Reference in a new issue