class TestWhosout(unittest.TestCase): def setUp(self): self.checker = WhosOutChecker(TEST_API_KEY, TEST_COMPANY, TEST_HOST) def test_get_whos_out(self): timeoffs = self.checker.get_whos_out() print('number of timeoffs returned:', len(timeoffs)) expected = [ (Employee('Sarah Surely', 'Sarah', 'Surely', None), Leave(date(2015, 5, 4), date(2015, 5, 4))), (Employee('Charlie Brown', 'Charlie', 'Brown', None), Leave(date(2015, 5, 21), date(2015, 5, 28)))] self.assertEqual(frozenset(expected), frozenset(timeoffs)) def test_where_is(self): ### TODO : Add test case for multiple employees with the same name whereabouts = self.checker.where_is('Sarah') expected = [(Employee('Sarah Surely', 'Sarah', 'Surely', None), Leave(date(2015, 5, 4), date(2015, 5, 4)))] self.assertEqual(frozenset(expected), frozenset(whereabouts)) def test_where_is_unknown(self): result = self.checker.where_is("Polly") self.assertEqual(frozenset(), frozenset(result)) def test_where_is_none(self): result = self.checker.where_is(None) self.assertEqual(frozenset(), frozenset(result)) def test_build_whosout_reply(self): timeoffs = [ (Employee('Sarah Surely', 'Sarah', 'Surely', None), Leave(date(2015, 5, 4), date(2015, 5, 4))), (Employee('Charlie Brown', 'Charles', 'Brown', None), Leave(date(2015, 5, 6), date(2015, 5, 8)))] reply = whosout.build_whosout_reply(timeoffs) self.assertIn('Sarah Surely: 4/5-4/5', reply) self.assertIn('Charlie Brown: 6/5-8/5', reply) def test_build_whereis_reply(self): whereabouts = [(Employee('Sarah Surely', 'Sarah', 'Surely', None), Leave(date(2015, 5, 4), date(2015, 5, 4)))] reply = whosout.build_whereis_reply('sarah', whereabouts) self.assertIn("Sarah Surely is currently on leave", reply) self.assertIn('from 4/5 to 4/5', reply)
def setUp(self): self.checker = WhosOutChecker(TEST_API_KEY, TEST_COMPANY, TEST_HOST)