diff --git a/drone.yaml b/drone.yaml index d11417d..c93ed54 100644 --- a/drone.yaml +++ b/drone.yaml @@ -3,14 +3,15 @@ pipeline: image: python commands: - pip install -r requirements.txt + - pip install flake8 - python3 test_tmdb.py + - flake8 --ignore=E501 build: image: alpine commands: - apk add zip - ./create_release.sh ${DRONE_COMMIT_SHA:0:8} - - ls *.mbp upload: image: uploader diff --git a/test_tmdb.py b/test_tmdb.py index 54c026a..0111ede 100644 --- a/test_tmdb.py +++ b/test_tmdb.py @@ -7,7 +7,7 @@ from sqlalchemy import create_engine class TestTmdbMethods(unittest.TestCase): - ### TMDB API + # TMDB API def test_search_item(self): movie = Movie() id = movie.search_title('Breakfast Club') @@ -16,19 +16,19 @@ class TestTmdbMethods(unittest.TestCase): def test_cast(self): movie = Movie() movie.search_title('Breakfast Club') - self.assertEqual('Anthony Michael Hall', movie.cast[0]) - + self.assertEqual('Emilio Estevez', movie.cast[0]) + def test_title(self): movie = Movie() movie.search_title('Breakfast Club') self.assertEqual('The Breakfast Club', movie.title) - + def test_overview(self): movie = Movie() movie.search_title('Breakfast Club') description = 'Five high school students from different walks of' self.assertEqual(description, movie.overview[:len(description)]) - + def test_change_language(self): movie = Movie() movie.set_language('en') @@ -38,7 +38,6 @@ class TestTmdbMethods(unittest.TestCase): def test_html_construction(self): movie = Movie() - tmdb = TmdbBot("","" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ) movie.query_details('550') constructor = MessageConstructor(movie) constructor.overview_length = 10 @@ -49,7 +48,7 @@ class TestTmdbMethods(unittest.TestCase):
Taken from www.themoviedb.org
""") def test_database_language(self): - engine = create_engine('sqlite:///test.db', echo = True) + engine = create_engine('sqlite:///test.db', echo=True) db = Database(engine) db.set_language('@testuser:example.com', 'de') self.assertEqual(str(db.get_language('@testuser:example.com')), 'de') @@ -75,14 +74,14 @@ class TestTmdbMethods(unittest.TestCase): self.assertEqual(id, 841) def test_split_year(self): - tmdb = TmdbBot("","" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ) + tmdb = TmdbBot("", "", "", "", "", "", "", "", "") title, year = tmdb.split_title_year('Dune') self.assertEqual('Dune', title) self.assertEqual(None, year) title, year = tmdb.split_title_year('Dune y:2020 ') self.assertEqual('Dune', title) self.assertEqual(2020, year) - + def test_set_poster_size(self): movie = Movie() size = movie.set_poster_size("w500") @@ -91,7 +90,7 @@ class TestTmdbMethods(unittest.TestCase): size = movie.set_poster_size("w666") self.assertEqual(size, None) - # TV Shows + # TV Shows def test_search_tvshow(self): movie = TvShow() id = movie.search_title('The Flash') @@ -102,16 +101,16 @@ class TestTmdbMethods(unittest.TestCase): movie.search_title('The Flash') self.assertEqual('The Flash', movie.title) - def test_cast(self): + def test_cast_2(self): movie = TvShow() movie.search_title('The Flash') - #self.assertEqual('Tom Cavanagh', movie.cast[0]) self.assertEqual('Danielle Panabaker', movie.cast[2]) - + def test_poster_path(self): 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") + if __name__ == '__main__': unittest.main() diff --git a/tmdb/__init__.py b/tmdb/__init__.py index 9047830..e69de29 100644 --- a/tmdb/__init__.py +++ b/tmdb/__init__.py @@ -1 +0,0 @@ -from .tmdb import TmdbBot diff --git a/tmdb/database.py b/tmdb/database.py index 9e2cf3b..97f3e4b 100644 --- a/tmdb/database.py +++ b/tmdb/database.py @@ -14,16 +14,15 @@ You should have received a copy of the GNU Affero General Public License along with tmdb-bot. If not, see{escape(self.movie.overview)[:self.overview_length]}{self.three_dotts()}
@@ -83,10 +83,10 @@ class TmdbBot(Plugin): async def send_notice(self, evt: MessageEvent, message: str = "") -> None: content = TextMessageEventContent( - msgtype=MessageType.NOTICE, format=Format.HTML, - body=message) + msgtype=MessageType.NOTICE, format=Format.HTML, + body=message) await evt.respond(content) - + async def send_help(self, evt: MessageEvent) -> None: html = """Use !tmdb id movie {tmdb id} to get movie detail for tmdb-id.
Use !tmdb movie {title} [y:{release year}] to get movie detail based on the given title.
@@ -109,7 +109,7 @@ class TmdbBot(Plugin): info=ImageInfo(mimetype='image/jpg')) await evt.respond(content) - def split_title_year(self, message : str) -> (str, int): + def split_title_year(self, message: str) -> (str, int): m = re.search(r'^(.*) (y:\d\d\d\d)', message) if m: title = m.group(1) @@ -117,12 +117,12 @@ class TmdbBot(Plugin): return (title, year) return (message, None) - def set_language(self, evt: MessageEvent, movie : TmdbApi): + def set_language(self, evt: MessageEvent, movie: TmdbApi): language = self.db.get_language(evt.sender) if language: movie.set_language(language) - def poster_size(self, evt: MessageEvent, movie : TmdbApi): + def poster_size(self, evt: MessageEvent, movie: TmdbApi): size = self.db.get_poster_size(evt.sender) if size: movie.set_poster_size(size) @@ -159,8 +159,8 @@ class TmdbBot(Plugin): await self.send_movie_info(evt, movie) else: content = TextMessageEventContent( - msgtype=MessageType.NOTICE, format=Format.HTML, - body=f"No movie found!") + msgtype=MessageType.NOTICE, format=Format.HTML, + body=f"No movie found!") await evt.respond(content) @command.new("movie-search", help="Movie lookup by Title") @@ -171,8 +171,8 @@ class TmdbBot(Plugin): async def movie_language(self, evt: MessageEvent, message: str = "") -> None: self.db.set_language(evt.sender, message) content = TextMessageEventContent( - msgtype=MessageType.NOTICE, format=Format.HTML, - body=f"Language set to {message}!") + msgtype=MessageType.NOTICE, format=Format.HTML, + body=f"Language set to {message}!") await evt.respond(content) async def set_poster_size(self, evt: MessageEvent, message: str = None) -> None: diff --git a/tmdb/tmdb_api.py b/tmdb/tmdb_api.py index e164ab9..cbe1c83 100644 --- a/tmdb/tmdb_api.py +++ b/tmdb/tmdb_api.py @@ -15,6 +15,7 @@ along with tmdb-bot. If not, see