Esempio n. 1
0
 def test_parser_runs_cli(self, mock_argparse):
     """
     Tests whether parser runs cli
     """
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     main()
     sys.stdout = sys.__stdout__
     self.assertIn("\n(Press Ctrl+C to quit)", capturedOutput.getvalue())
Esempio n. 2
0
 def test_parser_runs_tab(self, mock_argparse, mock_app, mock_threader):
     """
     Tests whether parser runs tab
     """
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     main()
     sys.stdout = sys.__stdout__
     self.assertIn("Firing up a browser tab!", capturedOutput.getvalue())
     self.assertTrue(mock_app.called)
Esempio n. 3
0
 def test_parser_prints_description(self, mock_argparse):
     """
     Tests whether prints its description
     """
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     main()
     sys.stdout = sys.__stdout__
     self.assertIn(
         "Get lyrics for the currently playing song on Spotify. Either --tab or --cli is\nrequired.",
         capturedOutput.getvalue())
 def test_parser_runs_tab_with_song_and_without_artist_search_value(
         self, mock_argparse, mock_app, mock_threader):
     """
     Tests whether tab recieves song and artist value or not
     """
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     main()
     sys.stdout = sys.__stdout__
     self.assertIn("Firing up a browser tab!", capturedOutput.getvalue())
     self.assertTrue(mock_app.called)
Esempio n. 5
0
 def test_parser_cli_works_when_same_song_playing(self, f_precheck, fake_lyrics, fake_spotify, mock_argparse):
     """
     Tests whether parser cli can raise SongNotPlaying
     """
     outputs = [('Panini', 'Lil Nas X'), ('Panini', 'Lil Nas X'), KeyboardInterrupt]
     fake_spotify.side_effect = outputs
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     with self.assertRaises((SystemExit, SameSongPlaying)):
         main()
     sys.stdout = sys.__stdout__
     self.assertIn("Bruhnini", capturedOutput.getvalue())
     self.assertIn("\nSure boss, exiting.", capturedOutput.getvalue())
Esempio n. 6
0
 def test_parser_cli_works_when_spotify_not_playing(self, f_precheck, fake_spotify, mock_argparse):
     """
     Tests whether parser prints Nothing Playing initially
     """
     outputs = [SpotifyNotRunning, KeyboardInterrupt]
     fake_spotify.side_effect = outputs
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     with self.assertRaises(SystemExit):
         main()
     sys.stdout = sys.__stdout__
     self.assertIn("\n(Press Ctrl+C to quit)", capturedOutput.getvalue())
     self.assertIn("Spotify appears to be paused or closed at the moment.", capturedOutput.getvalue())
     self.assertIn("\nSure boss, exiting.", capturedOutput.getvalue())
Esempio n. 7
0
 def test_parser_cli_changes_song(self, f_precheck, fake_lyrics, fake_spotify, mock_argparse):
     """
     Tests whether parser runs cli properly
     """
     outputs = [('Hello', 'Adele'), ('Panini', 'Lil Nas X'), ('Panini', 'Lil Nas X'),
                SpotifyNotRunning, KeyboardInterrupt]
     fake_spotify.side_effect = outputs
     fake_lyrics.side_effect = ['Yello', 'Bruhnini']
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     with self.assertRaises(SystemExit):
         main()
     sys.stdout = sys.__stdout__
     self.assertIn("\n(Press Ctrl+C to quit)", capturedOutput.getvalue())
     self.assertIn("\nYello", capturedOutput.getvalue())
     self.assertIn("Bruhnini", capturedOutput.getvalue())
     self.assertIn("\nSure boss, exiting.", capturedOutput.getvalue())
 def test_parser_runs_cli_with_song_and_without_artist(self, mock_argparse):
     with self.assertRaises(SystemExit):
         main()