class TestTimingServiceLocator (TestServiceLocator):
    
    def setup (self):
        self.slp = TimingServiceLocator(expire=2)
    
    def test_init_expire (self):
        assert self.slp.expire == 2
    
    def test_expire_services (self):
        self.slp.register("foo_service", "http://localhost:5900")
        start = time.time()
        self.slp.expire_services()
        assert time.time() < start + 2
        location = self.slp.locate("foo_service")
        assert location == "http://localhost:5900"
        time.sleep(3)
        assert (time.time() - start) > 2
        self.slp.expire_services()
        location = self.slp.locate("foo_service")
        assert location == ""