Esempio n. 1
0
 def test_process_leases_records_update(self):
     self.set_lease_state()
     self.patch(leases_module, 'send_leases', FakeMethod())
     new_leases = factory.make_random_leases()
     self.fake_leases_file(new_leases)
     process_leases(datetime.utcnow(), new_leases)
     self.assertIsNone(check_lease_changes())
Esempio n. 2
0
 def test_process_leases_records_update(self):
     self.set_lease_state()
     self.patch(leases_module, 'send_leases', FakeMethod())
     new_leases = factory.make_random_leases()
     self.fake_leases_file(new_leases)
     process_leases(datetime.utcnow(), new_leases)
     self.assertIsNone(check_lease_changes())
Esempio n. 3
0
 def test_check_lease_changes_returns_tuple_if_no_state_cached(self):
     self.set_lease_state()
     leases = factory.make_random_leases()
     leases_file = self.fake_leases_file(leases)
     self.assertEqual(
         (get_write_time(leases_file), leases),
         check_lease_changes())
Esempio n. 4
0
 def test_check_lease_changes_returns_tuple_if_leases_dropped(self):
     self.set_lease_state(
         datetime.utcnow() - timedelta(seconds=10),
         factory.make_random_leases())
     leases_file = self.fake_leases_file({})
     self.assertEqual(
         (get_write_time(leases_file), {}),
         check_lease_changes())
Esempio n. 5
0
 def test_check_lease_changes_returns_tuple_if_lease_added(self):
     leases = factory.make_random_leases()
     self.set_lease_state(datetime.utcnow() - timedelta(seconds=10),
                          leases.copy())
     leases[factory.getRandomIPAddress()] = factory.getRandomMACAddress()
     leases_file = self.fake_leases_file(leases)
     self.assertEqual((get_write_time(leases_file), leases),
                      check_lease_changes())
Esempio n. 6
0
 def test_check_lease_changes_returns_tuple_if_lease_added(self):
     leases = factory.make_random_leases()
     self.set_lease_state(
         datetime.utcnow() - timedelta(seconds=10), leases.copy())
     leases[factory.getRandomIPAddress()] = factory.getRandomMACAddress()
     leases_file = self.fake_leases_file(leases)
     self.assertEqual(
         (get_write_time(leases_file), leases),
         check_lease_changes())
Esempio n. 7
0
 def test_process_leases_records_state_before_sending(self):
     self.set_lease_state()
     self.patch(Omshell, 'create', FakeMethod())
     self.fake_leases_file({})
     self.patch(
         leases_module, 'send_leases', FakeMethod(failure=StopExecuting()))
     new_leases = factory.make_random_leases()
     try:
         process_leases(datetime.utcnow(), new_leases)
     except StopExecuting:
         pass
     self.fake_leases_file(new_leases)
     self.assertIsNone(check_lease_changes())
Esempio n. 8
0
 def test_process_leases_records_state_before_sending(self):
     self.set_lease_state()
     self.patch(Omshell, 'create', FakeMethod())
     self.fake_leases_file({})
     self.patch(leases_module, 'send_leases',
                FakeMethod(failure=StopExecuting()))
     new_leases = factory.make_random_leases()
     try:
         process_leases(datetime.utcnow(), new_leases)
     except StopExecuting:
         pass
     self.fake_leases_file(new_leases)
     self.assertIsNone(check_lease_changes())
Esempio n. 9
0
 def test_check_lease_changes_ignores_irrelevant_changes(self):
     leases = factory.make_random_leases()
     self.fake_leases_file(leases, age=10)
     self.set_lease_state(datetime.utcnow(), leases.copy())
     self.assertIsNone(check_lease_changes())
Esempio n. 10
0
 def test_check_lease_changes_returns_None_if_no_change(self):
     leases = factory.make_random_leases()
     leases_file = self.fake_leases_file(leases)
     self.set_lease_state(get_write_time(leases_file), leases.copy())
     self.assertIsNone(check_lease_changes())
Esempio n. 11
0
 def test_check_lease_returns_None_if_lease_file_does_not_exist(self):
     self.redirect_parser_to_non_existing_file()
     self.assertIsNone(check_lease_changes())
Esempio n. 12
0
 def test_check_lease_changes_ignores_irrelevant_changes(self):
     leases = factory.make_random_leases()
     self.fake_leases_file(leases, age=10)
     self.set_lease_state(datetime.utcnow(), leases.copy())
     self.assertIsNone(check_lease_changes())
Esempio n. 13
0
 def test_check_lease_changes_returns_None_if_no_change(self):
     leases = factory.make_random_leases()
     leases_file = self.fake_leases_file(leases)
     self.set_lease_state(get_write_time(leases_file), leases.copy())
     self.assertIsNone(check_lease_changes())
Esempio n. 14
0
 def test_check_lease_changes_returns_tuple_if_leases_dropped(self):
     self.set_lease_state(datetime.utcnow() - timedelta(seconds=10),
                          factory.make_random_leases())
     leases_file = self.fake_leases_file({})
     self.assertEqual((get_write_time(leases_file), {}),
                      check_lease_changes())
Esempio n. 15
0
 def test_check_lease_returns_None_if_lease_file_does_not_exist(self):
     self.redirect_parser_to_non_existing_file()
     self.assertIsNone(check_lease_changes())
Esempio n. 16
0
 def test_check_lease_changes_returns_tuple_if_no_state_cached(self):
     self.set_lease_state()
     leases = factory.make_random_leases()
     leases_file = self.fake_leases_file(leases)
     self.assertEqual((get_write_time(leases_file), leases),
                      check_lease_changes())