Esempio n. 1
0
 def test_simple(self):
     """Test we can assign slots to a Block that spans only few hours."""
     block1 = ScheduleBlock.objects.create(
         start_time=D.datetime(2013, 9, 22, 9, 0, 0, tzinfo=timezone.utc),
         end_time=D.datetime(2013, 9, 22, 19, 0, 0, tzinfo=timezone.utc))
     slot1 = Slot(start_time=D.datetime(2013,
                                        9,
                                        22,
                                        9,
                                        0,
                                        0,
                                        tzinfo=timezone.utc),
                  end_time=D.datetime(2013,
                                      9,
                                      22,
                                      10,
                                      20,
                                      0,
                                      tzinfo=timezone.utc))
     self.assertEqual(slot1.get_block(), block1)
     self.assertEqual(slot1.get_duration(), {'hours': 1, 'minutes': 20})
     # Check end and start times
     slot2 = Slot(start_time=D.datetime(2013,
                                        9,
                                        22,
                                        12,
                                        0,
                                        0,
                                        tzinfo=timezone.utc),
                  end_time=D.datetime(2013,
                                      9,
                                      22,
                                      13,
                                      0,
                                      0,
                                      tzinfo=timezone.utc))
     slot3 = Slot(start_time=D.datetime(2013,
                                        9,
                                        22,
                                        18,
                                        30,
                                        0,
                                        tzinfo=timezone.utc),
                  end_time=D.datetime(2013,
                                      9,
                                      22,
                                      19,
                                      0,
                                      0,
                                      tzinfo=timezone.utc))
     self.assertEqual(slot2.get_block(), block1)
     self.assertEqual(slot2.get_duration(), {'hours': 1, 'minutes': 0})
     self.assertEqual(slot3.get_block(), block1)
     self.assertEqual(slot3.get_duration(), {'hours': 0, 'minutes': 30})
     block1.delete()
Esempio n. 2
0
 def test_midnight(self):
     """Test that we can assign slots that span midnight to a block
        that spans midnight."""
     block1 = ScheduleBlock.objects.create(
         start_time=D.datetime(2013, 9, 22, 9, 0, 0, tzinfo=timezone.utc),
         end_time=D.datetime(2013, 9, 23, 8, 0, 0, tzinfo=timezone.utc))
     slot1 = Slot(start_time=D.datetime(2013,
                                        9,
                                        22,
                                        23,
                                        0,
                                        0,
                                        tzinfo=timezone.utc),
                  end_time=D.datetime(2013,
                                      9,
                                      23,
                                      1,
                                      0,
                                      0,
                                      tzinfo=timezone.utc))
     self.assertEqual(slot1.get_block(), block1)
     self.assertEqual(slot1.get_duration(), {'hours': 2, 'minutes': 0})
     block1.delete()