Browse Source

added new test - closes #1

pull/18/head
theycallmemac 3 years ago
parent
commit
709914d105
3 changed files with 44 additions and 0 deletions
  1. +1
    -0
      .travis.yml
  2. +6
    -0
      CHANGELOG.md
  3. +37
    -0
      tests/test_lookup.py

+ 1
- 0
.travis.yml View File

@@ -9,6 +9,7 @@ install:

script:
- python tests/test_available_now.py
- python tests/test_lookup.py
- python tests/test_builder.py

notifications:


+ 6
- 0
CHANGELOG.md View File

@@ -236,8 +236,14 @@ __contributor:__ theycallmemac
- tests the return value of the build_timetable function in dcurooms.py
- also tests the validity of the url built

- tests/test_lookup.py
- created test_lookup.py
- tests the output of an incorrect entry
- also checks the output is nothing when the room is indeed free

- .travis.yml
- added new test_builder.py test to scripts section
- added new test_lookup.py test too

---


+ 37
- 0
tests/test_lookup.py View File

@@ -0,0 +1,37 @@


import unittest
import sys
import datetime
import os
sys.path.append('../')

class LookupTestCase(unittest.TestCase):
def test_options(self):
room_result = os.system("cd scripts/ && python dcurooms.py -l CG12 21 1 1800 > ../tests/lookup_room_output.txt")
building_result = os.system("cd scripts/ && python dcurooms.py -lL 9 4 1500 > ../tests/lookup_building_output.txt")

self.assertTrue(room_result == 0) and self.assertTrue(building_result == 0)

def test_lookup_output(self):
if self.test_options():
with open('lookup_room_output.txt') as f:
for line in f:
if len(line.strip()[14:]) > 0:
self.assertEqual("Outside scheduled timetables. Try again at 08:00.", line.strip())
else:
self.assertEqual("", line.strip()[14:])

with open('lookup_building_output.txt') as f:
for line in f:
if len(line.strip()[14:]) > 0:
self.assertEqual("Outside scheduled timetables. Try again at 08:00.", line.strip())
else:
self.assertEqual("", line.strip()[14:])




if __name__ == '__main__':
unittest.main()


Loading…
Cancel
Save