Exemplo n.º 1
0
 def test_23_iter(self):
     pi1 = Mock_PaperInfo('Paper1', '7')
     pi2 = Mock_PaperInfo('Paper2', '5')
     pi3 = Mock_PaperInfo('Paper3', '3')
     hi = HouseInfo('New', 'Road', [pi1, pi2, pi3])
     it = hi.title_iter()
     self.assertEqual(next(it), pi1)
     self.assertEqual(next(it), pi2)
     self.assertEqual(next(it), pi3)
     with self.assertRaises(StopIteration):
         self.assertEqual(next(it), None)
Exemplo n.º 2
0
 def test_01_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo()
     self.assertEqual(
         e.exception.args[0],
         "__init__() missing 3 required positional arguments: 'name_or_number', 'road', and 'paper'"
     )
Exemplo n.º 3
0
 def test_02_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo(None)
     self.assertEqual(
         e.exception.args[0],
         "__init__() missing 2 required positional arguments: 'road' and 'paper'"
     )
Exemplo n.º 4
0
 def test_60_title_iter(self):
     pi1 = PaperInfo('Paper1', '125')
     pi2 = PaperInfo('Paper2', '135')
     pi3 = PaperInfo('Paper3', '246')
     pi4 = PaperInfo('Paper4', '157')
     hi = HouseInfo(20, 'Road1', [pi1, pi2, pi3, pi4])
     self.assertTrue(isinstance(hi._titles, list))
Exemplo n.º 5
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")
Exemplo n.º 6
0
 def test_51_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box=True)
     self.assertEqual(hi._use_box, DaySequence())
Exemplo n.º 7
0
 def test_57_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box=DaySequence(2))
     self.assertEqual(hi._use_box, {2})
Exemplo n.º 8
0
 def test_56_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box=2)
     self.assertEqual(hi._use_box, {2})
Exemplo n.º 9
0
 def test_14_init(self):
     with self.assertRaises(ValueError) as e:
         hi = HouseInfo(2, 'Road', [])
     self.assertEqual(
         e.exception.args[0],
         "Must provide a sequence with at least one 'PaperInfo' instance")
Exemplo n.º 10
0
 def test_08_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo(None, 'Road', None)
     self.assertEqual(e.exception.args[0],
                      "House must be identified by a string or integer")
Exemplo n.º 11
0
 def test_11_init(self):
     hi = HouseInfo('Special', 'Road', None)
     self.assertEqual(hi._titles, [])
Exemplo n.º 12
0
 def test_25_eq(self):
     hi1 = HouseInfo('Old Barn', 'Hall Lane', None)
     self.assertFalse(hi1 == 'Old Barn')
Exemplo n.º 13
0
 def test_05_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo(-2, None, None)
     self.assertEqual(e.exception.args[0],
                      "House number should be a positive integer")
Exemplo n.º 14
0
 def test_24_eq(self):
     hi1 = HouseInfo('Old Barn', 'Hall Lane', None)
     hi2 = HouseInfo('Old Barn', 'Hall Lane', None)
     self.assertFalse(id(hi1) == id(hi2))
     self.assertTrue(hi1 == hi2)
Exemplo n.º 15
0
'''
This is a test suite that will check if the _LimitList mixin class is correctly
operating on a specific object instance
'''

import unittest
from pydelivery.parser.parseround import _LimitList, HouseInfo, PaperInfo

pi = PaperInfo('Paper')
hi1 = HouseInfo(1, 'Road1', pi)
hi2 = HouseInfo('Name1', 'Road1', pi)
hi3 = HouseInfo('Name2', 'Road2', pi)

class Check_HouseList(_LimitList):
  def __init__(self, elems=None):
    super().__init__(HouseInfo, 'HouseInfo', elems)
    

class Test__LimitList(unittest.TestCase):
  def test_01_init(self):
    with self.assertRaises(TypeError) as e:
      ll = _LimitList()
    self.assertEqual(e.exception.args[0], "__init__() missing 2 required positional arguments: 'type_' and 'name'")
    
  def test_02_init(self):
    with self.assertRaises(TypeError) as e:
      ll = _LimitList(HouseInfo)
    self.assertEqual(e.exception.args[0], "__init__() missing 1 required positional argument: 'name'")
  
  def test_03_init(self):
    class Mock_Type:
Exemplo n.º 16
0
 def test_22_flags(self):
     pi = Mock_PaperInfo('Telegraph', '5')
     hi = HouseInfo(2, 'Road', pi, use_box=True)
     self.assertTrue('use_box' in hi.flags('4'))
Exemplo n.º 17
0
 def test_21_init(self):
     pi = Mock_PaperInfo('Telegraph', '1234567')
     hi = HouseInfo(2, 'Road', pi)
     self.assertEqual(hi._house, 2)
     self.assertEqual(hi._road, 'Road')
     self.assertEqual(hi._titles, [pi])
Exemplo n.º 18
0
 def test_18_init(self):
     with self.assertRaises(ValueError) as e:
         hi = HouseInfo(2, 'Road', ('Telegraph', ))
     self.assertEqual(e.exception.args[0],
                      "All elements must be 'PaperInfo' instances")
Exemplo n.º 19
0
 def test_07_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo('', None, None)
     self.assertEqual(e.exception.args[0],
                      "Must provide a non-empty house name")
Exemplo n.º 20
0
 def test_53_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box='')
     self.assertFalse(hasattr(hi, '_use_box'))
Exemplo n.º 21
0
 def test_09_init(self):
     hi = HouseInfo(2, 'Road', None)
     self.assertEqual(hi._titles, [])
Exemplo n.º 22
0
 def test_54_use_box(self):
     with self.assertRaises(ValueError) as e:
         hi = HouseInfo(20, 'Road1', Oper_Pi, use_box='8')
     self.assertEqual(e.exception.args[0],
                      "Day sequence contains no valid days")
Exemplo n.º 23
0
 def test_13_init(self):
     with self.assertRaises(TypeError) as e:
         hi = HouseInfo('Special', 2, None)
     self.assertEqual(e.exception.args[0],
                      "Must provide a non-empty road name")
Exemplo n.º 24
0
 def test_55_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box='67')
     self.assertEqual(hi._use_box, {6, 7})
Exemplo n.º 25
0
'''
This is the test suite for the HouseList object
'''

from pydelivery.parser.parseround import HouseList, HouseInfo
import unittest

# Declare some example HouseInfo instances
hi1 = HouseInfo('Name1', 'Road1', None)
hi2 = HouseInfo('Name1', 'Road2', None)
hi3 = HouseInfo('Name2', 'Road1', None)


class Test_HouseList(unittest.TestCase):
    def test_01_init(self):
        hl = HouseList()
        self.assertListEqual(hl, [])

    def test_02_init(self):
        hl = HouseList([hi1, hi2])
        self.assertListEqual(hl, [hi1, hi2])

    def test_03_equal(self):
        hl = HouseList([hi1, hi2])
        self.assertEqual(hl[0], hi1)

    def test_04_equal(self):
        hl = HouseList([hi1, hi2])
        self.assertEqual(hl[1], hi2)

    def test_05_equal(self):
Exemplo n.º 26
0
'''
This is the test suite for the parseround module
'''

from pydelivery.parser.parseround import HouseInfo, PaperInfo, RoundInfo
import unittest

# Define some objects to be used within the tests
pi1 = PaperInfo('Paper1')
hi1 = HouseInfo(20, 'Road1', pi1)

class TestParseRound(unittest.TestCase):
  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])