コード例 #1
0
 def test_04_init(self):
     ds = DaySequence('1245')
     dow = DayOfWeek()
     self.assertEqual(
         ds.days,
         set([
             dow['Monday'], dow['Tuesday'], dow['Thursday'], dow['Friday']
         ]))
コード例 #2
0
 def test_06_default(self):
     ds = DaySequence()
     dow = DayOfWeek()
     self.assertEqual(
         ds._def_days,
         set([
             dow['Monday'], dow['Tuesday'], dow['Wednesday'],
             dow['Thursday'], dow['Friday'], dow['Saturday'], dow['Sunday']
         ]))
     self.assertEqual(len(ds.days), 7)
コード例 #3
0
 def test_29_add_days(self):
     ds = DaySequence('1')
     ds.add_days('6')
     with self.assertRaises(ValueError) as e:
         ds.add_days('8')
     self.assertEqual(e.exception.args[0],
                      "Day sequence contains no valid days")
     self.assertEqual(ds.days, {1, 6})
コード例 #4
0
 def test_08_days(self):
     ds = DaySequence('7654321')
     self.assertEqual(ds.days, ds._def_days)
コード例 #5
0
 def test_07_days(self):
     ds = DaySequence('1234567')
     self.assertEqual(ds.days, ds._def_days)
コード例 #6
0
 def test_51_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box=True)
     self.assertEqual(hi._use_box, DaySequence())
コード例 #7
0
 def test_20_fail(self):
     with self.assertRaises(KeyError) as e:
         ds = DaySequence({5, 6, 8, 9})
     self.assertEqual(e.exception.args[0], 8)
コード例 #8
0
 def test_15_days(self):
     ds = DaySequence('0123456')
     self.assertEqual(ds.days, ds._def_days)
コード例 #9
0
 def test_13_days(self):
     ds = DaySequence({'Mon', 'Fri', 'Sun'})
     self.assertEqual(ds.days, {1, 5, 7})
コード例 #10
0
 def test_11_days(self):
     ds = DaySequence('MonTueSatFriThu')
     self.assertEqual(ds.days, {1, 2, 4, 5, 6})
コード例 #11
0
 def test_27_split(self):
     ds = DaySequence('2,45,7')
     self.assertEqual(ds.days, {2, 4, 5, 7})
コード例 #12
0
 def test_26_remove(self):
     ds1 = DaySequence({5, 6})
     ds2 = {5}
     ds1.remove_days(ds2)
     self.assertEqual(ds1.days, {6})
コード例 #13
0
 def test_25_add(self):
     ds1 = DaySequence({6})
     ds2 = DaySequence({5})
     ds1.add_days(ds2)
     self.assertEqual(ds1.days, {5, 6})
コード例 #14
0
 def test_24_embedded(self):
     ds1 = DaySequence({5, 6, 7})
     ds2 = DaySequence(ds1)
     self.assertEqual(ds2.days, ds1.days)
コード例 #15
0
 def test_22_fail(self):
     ds = DaySequence({'Mon', 'Tue'})
     self.assertEqual(ds.days, {1, 2})
コード例 #16
0
 def test_21_fail(self):
     with self.assertRaises(ValueError) as e:
         ds = DaySequence('8')
     self.assertEqual(e.exception.args[0],
                      'Day sequence contains no valid days')
コード例 #17
0
 def test_09_days(self):
     ds = DaySequence('12654')
     self.assertEqual(ds.days, {1, 2, 4, 5, 6})
コード例 #18
0
 def test_10_days_bad(self):
     ds = DaySequence('1843')
     self.assertEqual(ds.days, {1, 3, 4})
コード例 #19
0
 def test_28_dict(self):
     dct = dict(a=1, b=2, c=3)
     with self.assertRaises(ValueError) as e:
         ds = DaySequence(dct)
     self.assertEqual(e.exception.args[0],
                      "Unable to handle non-iterable day sequence")
コード例 #20
0
 def test_12_days(self):
     ds = DaySequence([1, 2, 3, 4, 5, 6, 7])
     self.assertEqual(ds.days, ds._def_days)
コード例 #21
0
 def test_17_days(self):
     ds = DaySequence(4)
コード例 #22
0
 def test_14_days(self):
     ds = DaySequence('06')
     self.assertEqual(ds.days, {6, 7})
コード例 #23
0
 def test_18_fail(self):
     with self.assertRaises(ValueError):
         ds = DaySequence('MoTuSaFr')
コード例 #24
0
 def test_16_days(self):
     ds = DaySequence()
     days = ds.parse('MonFri')
     self.assertIsNotNone(days)
     self.assertEqual(days, {1, 5})
コード例 #25
0
 def test_57_use_box(self):
     hi = HouseInfo(20, 'Road1', Oper_Pi, use_box=DaySequence(2))
     self.assertEqual(hi._use_box, {2})
コード例 #26
0
 def test_01_init(self):
     ds = DaySequence()
     self.assertEqual(ds.days, ds._def_days)
コード例 #27
0
 def test_05_init(self):
     ds = DaySequence('1245')
     dow = DayOfWeek()
     self.assertEqual(ds.days,
                      {dow.Monday, dow.Tuesday, dow.Thursday, dow.Friday})
コード例 #28
0
 def test_19_fail(self):
     with self.assertRaises(KeyError) as e:
         ds = DaySequence('MonTudWedFri')
     self.assertEqual(e.exception.args[0], 'Tud')
コード例 #29
0
 def __init__(self, name, dayseq, num_copies=1):
     self._name = name
     self._dayseq = DaySequence(dayseq)
     self._copies = num_copies