'A lease that has expired is removed from the persisted
configuration.'

def test_expired_lease_removed(self):

    timestep = 100
    node_id = uuid4()
    ids = (uuid4(), uuid4())
    now = self.clock.seconds()
    leases = Leases().acquire(datetime.fromtimestamp(now, UTC), ids[0], node_id, timestep)
    leases = leases.acquire(datetime.fromtimestamp(now, UTC), ids[1], node_id, (timestep * 2))
    new_config = Deployment(leases=leases)
    d = self.persistence_service.save(new_config)
    def saved(_):
        self.clock.advance((timestep - 1))
        before_first_expire = self.persistence_service.get().leases
        self.clock.advance(2)
        after_first_expire = self.persistence_service.get().leases
        self.clock.advance((timestep - 2))
        before_second_expire = self.persistence_service.get().leases
        self.clock.advance(2)
        after_second_expire = self.persistence_service.get().leases
        self.assertTupleEqual((before_first_expire, after_first_expire, before_second_expire, after_second_expire), (leases, leases.remove(ids[0]), leases.remove(ids[0]), leases.remove(ids[0]).remove(ids[1])))
    d.addCallback(saved)
    return d
