def test_select_tasks_select_nothing(self): '''calling tl with category only and answering nothing''' with patch('builtins.input', return_value=''): tl.select_tasks('ua') output = sys.stdout.getvalue().strip() self.assertEqual(output, '1) SF7-openafs\n2) SF801-kdump') self.assertEqual(tl.select_tasks('ua'), (None, None))
def test_select_tasks_out_of_range(self): '''calling tl with category only and giving out of range answer''' with patch('builtins.input', return_value='3'): tl.select_tasks('ua') output = sys.stdout.getvalue().strip() self.assertEqual(output, '1) SF7-openafs\n2) SF801-kdump\nInvalid task number') self.assertEqual(tl.select_tasks('ua'), (None, None))
def test_select_tasks_out_of_range(self): '''testing category only and giving out of range answer''' with patch('builtins.input', return_value='3'): tl.select_tasks('ua') output = sys.stdout.getvalue().strip() self.assertEqual(output, """1) SF801-kdump 2) SF7-openafs Invalid task number""")
def test_select_tasks_out_of_range(self): '''testing category only and giving out of range answer''' with patch('builtins.input', return_value='3'): tl.select_tasks('ua') output = sys.stdout.getvalue().strip() self.assertEqual( output, """1) SF801-kdump 2) SF7-openafs Invalid task number""")
def test_category_with_31_items_task_21(self): '''testing category with 31 entries and selecting twenty-first task''' with patch('builtins.input', return_value='21'): self.assertEqual(tl.select_tasks('lp'), ('lp', 'juju')) output = sys.stdout.getvalue().strip() self.assertEqual(output, """1) what 2) false 3) true 4) ifenslave 5) autoconf 6) autotools 7) make 8) grep 9) awk 10) binutils""")
def test_category_with_12_items_last_selection(self): '''testing category with 12 entries and selecting first task''' with patch('builtins.input', return_value='11'): self.assertEqual(tl.select_tasks('train'), ('train', 'python')) output = sys.stdout.getvalue().strip() self.assertEqual(output, """1) pascal 2) basic 3) erlang 4) nodejs 5) java 6) go 7) perl 8) apl 9) c 10) ruby""")
def test_category_with_exactly_10_items_no_selection(self): '''testing category with 10 entries and no selection''' with patch('builtins.input', return_value=''): self.assertEqual(tl.select_tasks('meet'), (None, None)) output = sys.stdout.getvalue().strip() self.assertEqual(output, """1) mom 2) kernel 3) sabdfl 4) server 5) foundation 6) mgr 7) team 8) supp 9) juju 10) maas""")
def test_category_with_31_items_task_21(self): '''testing category with 31 entries and selecting twenty-first task''' with patch('builtins.input', return_value='21'): self.assertEqual(tl.select_tasks('lp'), ('lp', 'juju')) output = sys.stdout.getvalue().strip() self.assertEqual( output, """1) what 2) false 3) true 4) ifenslave 5) autoconf 6) autotools 7) make 8) grep 9) awk 10) binutils""")
def test_category_with_12_items_last_selection(self): '''testing category with 12 entries and selecting first task''' with patch('builtins.input', return_value='11'): self.assertEqual(tl.select_tasks('train'), ('train', 'python')) output = sys.stdout.getvalue().strip() self.assertEqual( output, """1) pascal 2) basic 3) erlang 4) nodejs 5) java 6) go 7) perl 8) apl 9) c 10) ruby""")
def test_category_with_exactly_10_items_no_selection(self): '''testing category with 10 entries and no selection''' with patch('builtins.input', return_value=''): self.assertEqual(tl.select_tasks('meet'), (None, None)) output = sys.stdout.getvalue().strip() self.assertEqual( output, """1) mom 2) kernel 3) sabdfl 4) server 5) foundation 6) mgr 7) team 8) supp 9) juju 10) maas""")
def test_select_tasks_select_first_task(self): '''testing category only and selecting first task''' with patch('builtins.input', return_value='1'): self.assertEqual(tl.select_tasks('ua'), ('ua', 'SF801-kdump')) output = sys.stdout.getvalue().strip() self.assertEqual(output, '1) SF801-kdump\n2) SF7-openafs')
def test_select_tasks_select_0(self): '''testing category only and answering 0''' with patch('builtins.input', return_value='0'): self.assertEqual(tl.select_tasks('ua'), (None, None)) output = sys.stdout.getvalue().strip() self.assertEqual(output, '1) SF801-kdump\n2) SF7-openafs')
def test_select_tasks_select_nothing(self): '''testing category only and answering nothing''' with patch('builtins.input', return_value=''): self.assertEqual(tl.select_tasks('ua'), (None, None)) output = sys.stdout.getvalue().strip() self.assertEqual(output, '1) SF801-kdump\n2) SF7-openafs')
def test_select_tasks_select_valid(self): '''calling tl with category only and selecting first task''' with patch('builtins.input', return_value='1'): tl.select_tasks('ua') self.assertEqual(tl.select_tasks('ua'), ('ua', 'SF7-openafs'))