Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 def test_03_house_duplicate(self):
     ri = RoundInfo(1, 'Round1')
     ri._houses.append(mhi1)  # Prepopulate list of houses
     with self.assertRaises(ValueError) as e:
         ri.add_house(mhi1)
     self.assertEqual(e.exception.args[0],
                      "House is already present in round")
Ejemplo n.º 3
0
 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")
Ejemplo n.º 4
0
 def test_10_house_iter(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     riit = ri.house_iter()
     self.assertEqual(next(riit), mhi1)
     self.assertEqual(next(riit), mhi2)
     with self.assertRaises(StopIteration):
         next(riit)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 def test_01_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo()
     self.assertEqual(
         e.exception.args[0],
         "__init__() missing 2 required positional arguments: 'number' and 'name'"
     )
Ejemplo n.º 7
0
 def test_07_init(self):
     hi1 = Mock_HouseInfo('Name1', 'Road1')
     hi2 = ('Name2', 'Road1')
     with self.assertRaises(ValueError) as e:
         RoundInfo(1, 'Round1', [hi1, hi2])
     self.assertEqual(e.exception.args[0],
                      "All elements must be 'HouseInfo' instances")
Ejemplo n.º 8
0
 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")
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 def test_09_house_remove(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     ri.rem_house(mhi1)
     ri.rem_house(mhi2)
     self.assertEqual(ri._houses, [])
     with self.assertRaises(ValueError) as e:
         ri.rem_house(mhi1)
     self.assertEqual(e.exception.args[0], "House not present in round")
Ejemplo n.º 11
0
 def test_06_init(self):
     ri = RoundInfo(1, 'Round1')
     self.assertEqual(ri._number, 1)
     self.assertEqual(ri._name, 'Round1')
     self.assertEqual(ri._houses, [])
     self.assertIsNone(ri._order)
Ejemplo n.º 12
0
 def test_05_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo(1, '')
     self.assertEqual(e.exception.args[0],
                      "Must provide a name for the round")
Ejemplo n.º 13
0
 def test_04_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo(-1, '')
     self.assertEqual(e.exception.args[0],
                      "Must provide a positive number for round")
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 def test_03_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo(None, None)
     self.assertEqual(e.exception.args[0],
                      "Must provide a number for the round")
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 def test_02_house_type(self):
     ri = RoundInfo(1, 'Round1')
     ri.add_house(mhi1)
     self.assertEqual(ri._houses, [mhi1])
Ejemplo n.º 19
0
 def test_12_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo(6, 'Round1', None, OrderList())
     self.assertEqual(e.exception.args[0],
                      "Attempt to use round above maximum allowed")
Ejemplo n.º 20
0
 def test_10_init(self):
     with self.assertRaises(ValueError) as e:
         ri = RoundInfo(1, 'Round1', None, [])
     self.assertEqual(
         e.exception.args[0],
         "Must provide a sequence with at least one 'OrderInfo' instance")
Ejemplo n.º 21
0
 def test_08_init(self):
     with self.assertRaises(ValueError) as e:
         RoundInfo(1, 'Round1', [])
     self.assertEqual(
         e.exception.args[0],
         "Must provide a sequence with at least one 'HouseInfo' instance")
Ejemplo n.º 22
0
 def test_08_house_remove(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     ri.rem_house(mhi1)
     self.assertEqual(ri._houses, [mhi2])
Ejemplo n.º 23
0
 def test_02_init(self):
     with self.assertRaises(TypeError) as e:
         ri = RoundInfo(None)
     self.assertEqual(
         e.exception.args[0],
         "__init__() missing 1 required positional argument: 'name'")
Ejemplo n.º 24
0
 def test_11_order_iter(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     olit = ri.order_iter()
     with self.assertRaises(StopIteration):
         next(olit)
Ejemplo n.º 25
0
 def test_09_init(self):
     with self.assertRaises(ValueError) as e:
         RoundInfo(1, 'Round1', 'Name1')
     self.assertEqual(e.exception.args[0],
                      "All elements must be 'HouseInfo' instances")
Ejemplo n.º 26
0
 def test_15_eq_01(self):
     ri = RoundInfo(1, 'Round1', [mhi1, mhi2])
     oi = OrderInfo(14, 'Road1')
     self.assertFalse(ri == oi)
Ejemplo n.º 27
0
 def test_15_eq_04(self):
     ri1 = RoundInfo(1, 'Round1', None)
     ri2 = RoundInfo(1, 'Round1', [mhi2])
     self.assertFalse(ri1 == ri2)
     self.assertFalse(ri2 == ri1)
Ejemplo n.º 28
0
 def test_15_eq_05(self):
     ri1 = RoundInfo(1, 'Round1', [mhi1])
     ri2 = RoundInfo(1, 'Round1', [mhi2])
     self.assertFalse(ri1 == ri2)
Ejemplo n.º 29
0
 def test_13_init(self):
     ri = RoundInfo(1, 'Round1', None, OrderList())
     self.assertIsInstance(ri._order, OrderList)
Ejemplo n.º 30
0
 def test_01_add_house(self):
   '''Test the addition of a house to an empty round'''
   ri = RoundInfo(1, 'Round1')
   ri.add_house(hi1)
   self.assertEqual(ri._houses, [hi1])