Example #1
0
 def test_no_recordings_folder(self):
     fetch_server = Mock()
     fetch_server.url = URL_NO_RECORDINGS
     options = fetchtv.Options([CMD_RECORDINGS])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(0, len(results))
Example #2
0
 def test_get_shows(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options([CMD_SHOWS])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(8, len(results))
Example #3
0
 def test_exclude_one_show(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options(
         [CMD_RECORDINGS, f'{OPTION_EXCLUDE}="{SHOW_ONE}"'])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(7, len(results))
Example #4
0
 def test_get_all_recordings(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options([CMD_RECORDINGS])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(8, len(results))
     self.assertEqual(134, len(results[4]['items']))
Example #5
0
 def test_get_shows_json(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options([CMD_SHOWS, OPTION_JSON])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     output = fetchtv.print_recordings(results)
     output = json.loads(output)
     self.assertEqual(8, len(output))
Example #6
0
 def test_get_two_show_recording(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options(
         [CMD_RECORDINGS, f'{OPTION_FOLDER}="{SHOW_ONE}, {SHOW_TWO}"'])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(3, len(
         results))  # Test data returns LEGO Masters and Lego Masters....
Example #7
0
 def test_get_one_show_recording(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options(
         [CMD_RECORDINGS, f'{OPTION_FOLDER}="{SHOW_ONE}"'])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(1, len(results))
     self.assertEqual(134, len(results[0]['items']))
Example #8
0
 def test_get_recordings_items_json(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options([CMD_IS_RECORDING, OPTION_JSON])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     output = fetchtv.print_recordings(results)
     output = json.loads(output)
     self.assertEqual(1, len(output))
     self.assertEqual(1, len(output[0]['items']))
Example #9
0
 def test_exclude_two_shows(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options(
         [CMD_RECORDINGS, f'{OPTION_EXCLUDE}="{SHOW_ONE}, {SHOW_TWO}"'])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(
         5, len(results)
     )  # Test data has LEGO Masters and Lego Masters - both are matched
Example #10
0
 def test_get_two_recording_item(self):
     fetch_server = Mock()
     fetch_server.url = URL_DUMMY
     options = fetchtv.Options([
         CMD_RECORDINGS, f'{OPTION_FOLDER}="{SHOW_ONE}"',
         f'{OPTION_TITLE}="{SHOW_ONE_EP_ONE}, {SHOW_ONE_EP_TWO}"'
     ])
     results = fetchtv.get_fetch_recordings(fetch_server, options)
     fetchtv.print_recordings(results)
     self.assertEqual(1, len(results))
     self.assertEqual(2, len(results[0]['items']))
    def test_get_episode(self):
        fetch_server = fetchtv.discover_fetch(FETCHTV_IP, FETCHTV_PORT)
        with patch('fetchtv_upnp.download_file', Mock()):
            results = fetchtv.get_fetch_recordings(fetch_server, fetchtv.Options(
                [VAL_IP, VAL_PORT,
                 f'{OPTION_FOLDER}="{SHOW_ONE}"',
                 f'{OPTION_TITLE}="{SHOW_ONE_EP_TWO}"', CMD_RECORDINGS, OPTION_OVERWRITE, f'{OPTION_SAVE}="{SAVE_FOLDER}"']))

        # Contains 1 show
        self.assertTrue(
            len(list(result for result in results if result['title'] in [SHOW_ONE])) == 1)

        # Contains 1 episode
        items = list(result for result in results if result['title'] == SHOW_ONE)[0]['items']
        self.assertTrue(len(items) == 1)
        self.assertTrue(len(list(item for item in items if item.title.startswith(SHOW_ONE_EP_TWO))) == 1)
    def test_get_shows_episodes(self):
        fetch_server = fetchtv.discover_fetch(FETCHTV_IP, FETCHTV_PORT)
        results = fetchtv.get_fetch_recordings(
            fetch_server,
            fetchtv.Options([VAL_IP, VAL_PORT,
                             f'{OPTION_FOLDER}="{SHOW_ONE}, {SHOW_TWO}"',
                             f'{OPTION_TITLE}="{SHOW_ONE_EP_ONE}, {SHOW_ONE_EP_TWO}"',
                             CMD_RECORDINGS,
                             OPTION_OVERWRITE,
                             f'{OPTION_SAVE}="{SAVE_FOLDER}"']))

        # Contains both shows
        self.assertTrue(len(list(result for result in results if result['title'] in [SHOW_ONE, SHOW_TWO])) == 2)

        # Contains both episodes
        items = list(result for result in results if result['title'] == SHOW_ONE)[0]['items']
        self.assertTrue(len(items) == 2)
        self.assertTrue(len(list(item for item in items if item.title.startswith(SHOW_ONE_EP_ONE))) == 1)
        self.assertTrue(len(list(item for item in items if item.title.startswith(SHOW_ONE_EP_TWO))) == 1)
 def test_get_recordings(self):
     fetch_server = fetchtv.discover_fetch(ip=TestUpnp.FETCHTV_IP,
                                           port=TestUpnp.FETCHTV_PORT)
     recordings = fetchtv.get_fetch_recordings(fetch_server)
     self.assertTrue(recordings != False)
 def test_get_recordings(self):
     fetch_server = fetchtv.discover_fetch(ip=FETCHTV_IP, port=FETCHTV_PORT)
     recordings = fetchtv.get_fetch_recordings(fetch_server, fetchtv.Options(''))
     self.assertTrue(recordings)