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.

39 line
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 test_options(self):
  8. room_result = os.system("""cd scripts &&
  9. python dcurooms -l CG12 21 1 1800
  10. > ../tests/lookup_room_output.txt""")
  11. building_result = os.system("""cd scripts &&
  12. python dcurooms -lL 9 4 1500
  13. > ../tests/lookup_building_output.txt""")
  14. self.assertTrue(room_result == 0)
  15. self.assertTrue(building_result == 0)
  16. def test_lookup_output(self):
  17. if self.test_options():
  18. with open('lookup_room_output.txt') as f:
  19. for line in f:
  20. if len(line.strip()[14:]) > 0:
  21. self.assertEqual("""Outside scheduled timetables.
  22. Try again at 08:00.""", line.strip())
  23. else:
  24. self.assertEqual("", line.strip()[14:])
  25. with open('lookup_building_output.txt') as f:
  26. for line in f:
  27. if len(line.strip()[14:]) > 0:
  28. self.assertEqual("""Outside scheduled timetables.
  29. Try again at 08:00.""", line.strip())
  30. else:
  31. self.assertEqual("", line.strip()[14:])
  32. if __name__ == '__main__':
  33. unittest.main()