зеркало из https://github.com/mozilla/bugbug.git
Consider remote DB old if there is no version file yet
This commit is contained in:
Родитель
785aeca537
Коммит
3747171716
|
@ -38,6 +38,8 @@ def is_old_version(path):
|
|||
r = requests.get(
|
||||
urljoin(DATABASES[path]["url"], f"{os.path.basename(path)}.version")
|
||||
)
|
||||
if r.status_code == 404:
|
||||
return True
|
||||
r.raise_for_status()
|
||||
prev_version = int(r.text)
|
||||
|
||||
|
|
|
@ -252,14 +252,24 @@ def test_is_old_version(tmp_path):
|
|||
db_path = tmp_path / "prova.json"
|
||||
db.register(db_path, url_zst, 1, support_files=[])
|
||||
|
||||
responses.add(responses.GET, url_version, status=200, body="42")
|
||||
|
||||
assert os.path.exists(db_path.with_suffix(db_path.suffix + ".version"))
|
||||
|
||||
responses.add(responses.GET, url_version, status=404)
|
||||
responses.add(responses.GET, url_version, status=200, body="1")
|
||||
responses.add(responses.GET, url_version, status=200, body="42")
|
||||
|
||||
# When the remote version file doesn't exist, we consider the db as being old.
|
||||
assert db.is_old_version(db_path)
|
||||
|
||||
# When the remote version file exists and returns the same version as the current db, we consider the remote db as not being old.
|
||||
assert not db.is_old_version(db_path)
|
||||
|
||||
# When the remote version file exists and returns a newer version than the current db, we consider the remote db as not being old.
|
||||
assert not db.is_old_version(db_path)
|
||||
|
||||
db.register(db_path, url_zst, 43, support_files=[])
|
||||
|
||||
# When the remote version file exists and returns an older version than the current db, we consider the remote db as being old.
|
||||
assert db.is_old_version(db_path)
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче