-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestGenerateSynTrips.py
27 lines (23 loc) · 1.07 KB
/
TestGenerateSynTrips.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import unittest
import tempfile
import os
import subprocess as sp
# Successes will need to use docker-compose to ensure that there is a server
# and an OTP instance
class TestGenerateSynTripFailures(unittest.TestCase):
def testNoArguments(self):
with open("/dev/null", "w") as devnull:
retcode = sp.call("PYTHONPATH=. python bin/generate_syn_trips.py",
stderr=devnull, shell=True)
self.assertEqual(retcode, 2)
def testNoTransitionProb(self):
with open("/dev/null", "w") as devnull:
retcode = sp.call("PYTHONPATH=. OTP_SERVER=http://dummy python bin/generate_syn_trips.py 10",
stderr=devnull, shell=True)
self.assertEqual(retcode, 1)
def testWorkingVersion(self):
with tempfile.TemporaryDirectory() as td:
outfile = td +"/population.xml"
retcode = sp.call("PYTHONPATH=. python bin/generate_syn_trips.py 10 --generate_random_prob --outfile %s" % outfile, shell=True)
self.assertEqual(retcode, 0)
self.assertTrue(os.path.exists(outfile))