diff --git a/scripts/__init__.py b/scripts/__init__.py index ddcd4b7..e1acfaa 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,5 +1,8 @@ +''' +init file for scripts +''' from .get_metadata import (get_show_metadata, write_show_metadata, _format_episode_metadata, get_episode_metadata, - write_episode_metadata) \ No newline at end of file + write_episode_metadata) diff --git a/scripts/get_metadata.py b/scripts/get_metadata.py index 77c68d7..a1fc7db 100644 --- a/scripts/get_metadata.py +++ b/scripts/get_metadata.py @@ -71,7 +71,6 @@ def write_show_metadata(output_file, dict_data): raise TypeError("output_file must be of type str.") if len(output_file) < 5 or '.json' not in output_file: raise ValueError('Provide a valid output_file of .json type.') - if not dict_data: raise ValueError("Provide dict_data parameter!") if len(dict_data.keys()) == 0: @@ -79,8 +78,7 @@ def write_show_metadata(output_file, dict_data): with open(output_file, 'w', encoding="utf-8") as (outfile, error): if error: raise IOError(error) - else: - json.dump(dict_data, outfile, sort_keys=True, indent=2) + json.dump(dict_data, outfile, sort_keys=True, indent=2) def _format_episode_metadata(episode_metadata): ''' @@ -149,7 +147,6 @@ def write_episode_metadata(output_file, episodes_data): raise TypeError("output_file must be of type str.") if len(output_file) < 4 or '.csv' not in output_file: raise ValueError('Provide a valid output_file of .csv type.') - if not episodes_data: raise ValueError("Provide episodes_data parameter!") if len(episodes_data.keys()) == 0: diff --git a/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py b/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py index 9aa4d6e..6d22339 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py +++ b/thronetalk-game-of-thrones-summarizer/tests/mock_functions.py @@ -1,7 +1,9 @@ -from io import StringIO +''' +Mock functions for testing purposes. +''' import pandas as pd -def mocked_read_csv_ouput_dialogues(*args): +def mocked_read_csv_ouput_dialogues(): """ Mocking pandas' read_csv function for output_dialogues. """ @@ -51,6 +53,6 @@ def mocked_read_csv_ouput_dialogues(*args): ''' lines = data_output_dialogues_raw.splitlines() data = [line.split(',') for line in lines[1:]] - df = pd.DataFrame(data[1:], columns=data[0]) + dataframe = pd.DataFrame(data[1:], columns=data[0]) # mock_output_dialogues_raw = pd.read_csv(StringIO(data_output_dialogues_raw)) - return df \ No newline at end of file + return dataframe diff --git a/thronetalk-game-of-thrones-summarizer/tests/test_get_metadata.py b/thronetalk-game-of-thrones-summarizer/tests/test_get_metadata.py index 3457d9b..025c0e8 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/test_get_metadata.py +++ b/thronetalk-game-of-thrones-summarizer/tests/test_get_metadata.py @@ -23,19 +23,15 @@ # # def test_get_show_metadata_smoke(self): # # '''Smoke test to make sure the function runs properly.''' # # get_show_metadata("0944947") - # # def test_write_show_metadata_smoke(self): # # '''Smoke test to make sure the function runs properly.''' # # write_show_metadata(self.mock_path, self.mock_data) - # # def test__format_episode_metadata_smoke(self): # # '''Smoke test to make sure the function runs properly.''' # # _format_episode_metadata(self.mock_data) - # # def test_get_episode_metadata_smoke(self): # # '''Smoke test to make sure the function runs properly.''' # # get_episode_metadata() - # # def test_write_episode_metadata_smoke(self): # # '''Smoke test to make sure the function runs properly.''' # # write_episode_metadata(self.mock_path, self.mock_data) @@ -73,7 +69,6 @@ # # _format_episode_metadata() # with self.assertRaises(ValueError): # _format_episode_metadata({}) - # # def test_edge_invalid_write_episode_metadata(self): # # '''Edge test for write_episode_metadata function.''' # # # Check values of first parameter @@ -92,4 +87,4 @@ # # write_episode_metadata(self.mock_path, {}) # if __name__ == "__main__": -# unittest.main() \ No newline at end of file +# unittest.main() diff --git a/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py b/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py index ef517ca..1811491 100644 --- a/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py +++ b/thronetalk-game-of-thrones-summarizer/tests/test_visualization_generator.py @@ -3,7 +3,7 @@ Consists of smoke tests, one-shot test and edge tests. ''' import unittest -from unittest.mock import patch +# from unittest.mock import patch from utils import VisualizationGenerator # from . import mock_functions @@ -12,8 +12,9 @@ class TestVisualizationGenerator(unittest.TestCase): # Edge tests def test_init_error(self): + '''Edge tests for VisualizationGenerator''' with self.assertRaises(TypeError): - VisualizationGenerator() + VisualizationGenerator() # pylint: disable=no-value-for-parameter with self.assertRaises(ValueError): VisualizationGenerator("","","","") with self.assertRaises(ValueError): @@ -29,26 +30,27 @@ def test_init_error(self): # recommender = Recommender(meta=imdb, scripts=script) # self.assertEqual(recommender.weights, [1, 1, 0.8, 0.5, 0.2, 0.2, 0.4]) # self.assertIsNotNone(recommender.vector_list) - # @patch('scripts.visualization_generator.pd.read_csv', # side_effect=mock_functions.mocked_read_csv_ouput_dialogues) def test_wordcloud_error(self): - vg = VisualizationGenerator(1,1,1,2) + '''Edge tests for wordcloud generation function''' + v_g = VisualizationGenerator(1,1,1,2) with self.assertRaises(TypeError): - vg.multiWordCloud() + v_g.multiWordCloud() # pylint: disable=no-value-for-parameter with self.assertRaises(ValueError): - vg.multiWordCloud([]) + v_g.multiWordCloud([]) with self.assertRaises(ValueError): - vg.multiWordCloud(['', '']) + v_g.multiWordCloud(['', '']) - def test_sentimentAnalysisVisualization_error(self): - vg = VisualizationGenerator(1,1,1,2) + def test_sentiment_analysis_visualization_error(self): + '''Edge tests for sentiment analysis viz generation function''' + v_g = VisualizationGenerator(1,1,1,2) with self.assertRaises(TypeError): - vg.sentimentAnalysisVisualization() + v_g.sentimentAnalysisVisualization() # pylint: disable=no-value-for-parameter with self.assertRaises(ValueError): - vg.sentimentAnalysisVisualization([]) + v_g.sentimentAnalysisVisualization([]) with self.assertRaises(ValueError): - vg.sentimentAnalysisVisualization(['', '']) + v_g.sentimentAnalysisVisualization(['', '']) # Smoke tests # @patch('scripts.visualization_generator.pd.read_csv', @@ -60,4 +62,4 @@ def test_sentimentAnalysisVisualization_error(self): # vg.sentimentAnalysisVisualization(top_3_characters) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/thronetalk-game-of-thrones-summarizer/utils/__init__.py b/thronetalk-game-of-thrones-summarizer/utils/__init__.py index c576696..a1d17b5 100644 --- a/thronetalk-game-of-thrones-summarizer/utils/__init__.py +++ b/thronetalk-game-of-thrones-summarizer/utils/__init__.py @@ -1 +1,2 @@ -from .visualization_generator import VisualizationGenerator \ No newline at end of file +'''init file for utils''' +from .visualization_generator import VisualizationGenerator