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