def test_no_file_initially_with_wait(self, monkeypatch): self.monkeypatch_sleep(monkeypatch, add_file_midway=True) self.monkeypatch_load(monkeypatch) load._load_source(self._source) assert self.load_counter == 1 assert self.sleepcount == 2 assert self.total_sleep == 2.0
def test_no_file_with_wait(self, monkeypatch): self.monkeypatch_sleep(monkeypatch) self.monkeypatch_load(monkeypatch) with raises(BlueSkyUnavailableResourceError) as e_info: load._load_source(self._source) assert self.load_counter == 0 # load never called assert self.sleepcount == 4 assert self.total_sleep == 4.0
def test_no_file_initially_with_backoff_wait(self, monkeypatch): self.monkeypatch_sleep(monkeypatch, add_file_midway=True) self.monkeypatch_load(monkeypatch) self._source['wait']['strategy'] = 'backoff' load._load_source(self._source) assert self.load_counter == 1 assert self.sleepcount == 2 assert self.total_sleep == 3.0
def test_file_exists_with_wait(self, monkeypatch): self.monkeypatch_sleep(monkeypatch) self.monkeypatch_load(monkeypatch) with open(self._filename, 'w') as f: f.write('{}') load._load_source(self._source) assert self.load_counter == 1 assert self.sleepcount == 0 assert self.total_sleep == 0.0