def test_13_iter(self):
     oi1 = OrderInfo('House1', 'Road2')
     oi2 = OrderInfo(14, 'Road1')
     ol = OrderList([oi1, oi2])
     ri = RoundInfo(3, 'Round3', [mhi1, mhi2], ol)
     riit = iter(ri)
     self.assertEqual(next(riit), oi1)
     self.assertEqual(next(riit), oi2)
     with self.assertRaises(StopIteration):
         next(riit)
 def test_12_order_iter(self):
     oi1 = OrderInfo('House1', 'Road2')
     oi2 = OrderInfo(14, 'Road1')
     ol = OrderList([oi1, oi2])
     ri = RoundInfo(2, 'Round2', [mhi1, mhi2], ol)
     olit = ri.order_iter()
     self.assertEqual(next(olit), oi1)
     self.assertEqual(next(olit), oi2)
     with self.assertRaises(StopIteration):
         next(olit)
Exemple #3
0
 def test_01_init(self):
     with self.assertRaises(TypeError) as e:
         oi = OrderInfo()
     self.assertEqual(
         e.exception.args[0],
         "__init__() missing 2 required positional arguments: 'name_or_number' and 'road'"
     )
 def test_04_house_remove(self):
     ri = RoundInfo(1, 'Round1', [mhi1])
     oi = OrderInfo(14, 'Road1')
     with self.assertRaises(ValueError) as e:
         ri.rem_house(oi)
     self.assertEqual(e.exception.args[0],
                      "Can only remove instances of HouseInfo")
 def test_01_house_type(self):
     ri = RoundInfo(1, 'Round1')
     oi = OrderInfo(14, 'Road1')
     with self.assertRaises(ValueError) as e:
         ri.add_house(oi)
     self.assertEqual(e.exception.args[0],
                      "Can only add instances of HouseInfo")
 def test_11_init(self):
     oi = [
         HouseInfo('Name', 'Road1', PaperInfo('Telegraph')),
         OrderInfo('Name', 'Road')
     ]
     with self.assertRaises(ValueError) as e:
         ri = RoundInfo(1, 'Round1', None, oi)
     self.assertEqual(e.exception.args[0],
                      "All elements must be 'OrderInfo' instances")
Exemple #7
0
 def test_08_init(self):
     oi = OrderInfo('Name', 'Road')
Exemple #8
0
 def test_07_init(self):
     with self.assertRaises(TypeError) as e:
         oi = OrderInfo('Name', 0)
     self.assertEqual(e.exception.args[0],
                      "Must provide a non-empty road name")
Exemple #9
0
 def test_05_init(self):
     with self.assertRaises(TypeError) as e:
         oi = OrderInfo(-1, None)
     self.assertEqual(e.exception.args[0],
                      "House number should be a positive integer")
Exemple #10
0
 def test_04_init(self):
     with self.assertRaises(TypeError) as e:
         oi = OrderInfo('', '')
     self.assertEqual(e.exception.args[0],
                      'Must provide a non-empty house name')
Exemple #11
0
 def test_02_init(self):
     with self.assertRaises(TypeError) as e:
         oi = OrderInfo(None, None)
     self.assertEqual(e.exception.args[0],
                      'House must be identified by a string or integer')
 def test_15_eq_08(self):
     oi1 = OrderInfo(14, 'Road1')
     ri1 = RoundInfo(1, 'Round1', [mhi1], [oi1])
     ri2 = RoundInfo(1, 'Round1', [mhi1], [oi1])
     self.assertTrue(ri1 == ri2)
 def test_15_eq_07(self):
     oi1 = OrderInfo(14, 'Road1')
     oi2 = OrderInfo(14, 'Road2')
     ri1 = RoundInfo(1, 'Round1', [mhi1], [oi1])
     ri2 = RoundInfo(1, 'Round1', [mhi1], [oi2])
     self.assertFalse(ri1 == ri2)
 def test_15_eq_06(self):
     oi1 = OrderInfo(14, 'Road1')
     ri1 = RoundInfo(1, 'Round1', [mhi1], None)
     ri2 = RoundInfo(1, 'Round1', [mhi1], [oi1])
     self.assertFalse(ri1 == ri2)
     self.assertFalse(ri2 == ri1)
 def test_15_eq_01(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     oi = OrderInfo(14, 'Road1')
     self.assertFalse(ri == oi)