Ejemplo n.º 1
0
def main():
    print("*********MAIN MENU***********\n")

    choice = get_user_choice('List Subscribed Shows',
                             'Search',
                             'Quit',
                             index=True)

    if choice == 0:
        shows = [{
            'name': 'Supergirl',
            'release_year': 2016,
            'source': 'TVGuide'
        }]  # TODO - Read and Parse shows from 'shows.json'
        return list_shows(*shows)
    elif choice == 1:
        sources = ['TVGuide']  # TODO - Read shows from .py file.
        source = get_user_choice(*sources, none_option='Main Menu')
        return main() if source is None else search_source(source)
    elif choice == 2:
        sys.exit()
Ejemplo n.º 2
0
	def test_returns_none(self, input_mock, print_mock):
		self.assertIsNone(app.get_user_choice('b', 'c', none_option = 'a'))

		reset_mocks(input_mock, print_mock)

		self.assertIsNone(app.get_user_choice('e', 'f', none_option = 'd', index = True))
Ejemplo n.º 3
0
	def test_returns_index(self, input_mock, print_mock):
		self.assertEqual(app.get_user_choice('a', 'b', 'c', index = True), 0)

		reset_mocks(input_mock, print_mock)

		self.assertEqual(app.get_user_choice('a', 'b', 'c', index = True), 2)
Ejemplo n.º 4
0
	def test_invalid_min(self, input_mock, print_mock):
		with self.assertRaises(StopIteration):
			app.get_user_choice('g', 'h')
		input_mock.assert_called_with('> ')
		self.assertCalls(print_mock, '1: g', '2: h', '\nPlease enter your choice:', 'You must only enter either 1, or 2.\nPlease try again')
Ejemplo n.º 5
0
	def test_non_digit(self, input_mock, print_mock):
		with self.assertRaises(StopIteration):
			app.get_user_choice('c', 'd')
		input_mock.assert_called_with('> ')
		self.assertCalls(print_mock, '1: c', '2: d', '\nPlease enter your choice:', 'You must only enter either 1, or 2.\nPlease try again')
Ejemplo n.º 6
0
	def test_returns_chosen(self, input_mock, print_mock):
		self.assertEqual(app.get_user_choice('a', 'b'), 'b')
		self.assertCalls(print_mock, '1: a', '2: b', '\nPlease enter your choice:')
		self.assertCalls(input_mock, '> ')