From 081b957b451134e9427714858ed06efdeabdd993 Mon Sep 17 00:00:00 2001 From: Malar Kannan Date: Mon, 3 Jul 2017 17:19:51 +0530 Subject: [PATCH] added tests --- cyclic_contracts.py | 9 +++++---- cyclic_contracts_test.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cyclic_contracts.py b/cyclic_contracts.py index cd897a1..4b46276 100644 --- a/cyclic_contracts.py +++ b/cyclic_contracts.py @@ -1,4 +1,4 @@ -from cyclic_utils import CYCLE_LIMIT,rem_routes +from cyclic_utils import rem_routes class Route(object): """docstring for Route.""" @@ -67,7 +67,8 @@ class Transporter(object): if len(unfulfilled) > 0: print "Contracts from ",repr(unfulfilled) + def contract_corridors(self): + return rem_routes(self.contract_routes()) - -# Transporter.from_file('./contracts.txt').contracts_required() -Transporter.from_file('./contracts.txt').contracts_required() +if __name__ == '__main__': + Transporter.from_file('./contracts.txt').contracts_required() diff --git a/cyclic_contracts_test.py b/cyclic_contracts_test.py index 0d26d19..e2588f4 100644 --- a/cyclic_contracts_test.py +++ b/cyclic_contracts_test.py @@ -1,14 +1,18 @@ import unittest -import cyclic_contracts +from cyclic_contracts import Transporter class CyclicTest(unittest.TestCase): """docstring for CyclicTest.""" - def test_loads(): - - + def test_contract(self): + cc = Transporter.from_file("./contracts.txt").contract_corridors() + self.assertEqual(cc, [('Mumbai', 'Bangalore')]) + def test_partial(self): + cc = Transporter.from_file( + "./contracts_partial.txt").contract_corridors() + self.assertEqual(cc, [('Mumbai', 'Kolkata'), ('Chennai', 'Kolkata')]) if __name__ == '__main__': unittest.main()