A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.5 KiB

  1. import unittest
  2. import sys
  3. import datetime
  4. import os
  5. sys.path.append('.')
  6. class LookupTestCase(unittest.TestCase):
  7. def setUp(self):
  8. room_result = os.system(
  9. """python scripts/dcurooms -l CG12 21 1 1800 > tests/lookup_room_output.txt""")
  10. building_result = os.system(
  11. """python scripts/dcurooms -lL 9 4 1500 > tests/lookup_building_output.txt""")
  12. self.assertTrue(room_result == 0 and building_result == 0)
  13. def test_lookup_output(self):
  14. if self.setUp():
  15. with open('lookup_room_output.txt') as f:
  16. for line in f:
  17. if len(line.strip()[14:]) > 0:
  18. self.assertEqual("""Outside scheduled timetables.
  19. Try again at 08:00.""", line.strip())
  20. else:
  21. self.assertEqual("", line.strip()[14:])
  22. self.tearDown()
  23. with open('lookup_building_output.txt') as f:
  24. for line in f:
  25. if len(line.strip()[14:]) > 0:
  26. self.assertEqual("""Outside scheduled timetables.
  27. Try again at 08:00.""", line.strip())
  28. else:
  29. self.assertEqual("", line.strip()[14:])
  30. self.tearDown()
  31. def tearDown(self):
  32. del_result = os.system("""rm tests/*.txt""")
  33. self.assertTrue(del_result == 0)
  34. if __name__ == '__main__':
  35. unittest.main()