зеркало из https://github.com/mozilla/bugbug.git
Родитель
203f144781
Коммит
e3b4d3fcc8
|
@ -13,7 +13,7 @@ from bugbug import bugzilla, repository
|
|||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "fixtures")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture
|
||||
def mock_data(tmp_path_factory):
|
||||
tmp_path = tmp_path_factory.mktemp("")
|
||||
os.mkdir(tmp_path / "data")
|
||||
|
|
|
@ -220,6 +220,65 @@ def test_hg_log(fake_hg_repo):
|
|||
assert commits[2].node == revision4
|
||||
|
||||
|
||||
@responses.activate
|
||||
def test_download_commits(fake_hg_repo):
|
||||
hg, local, remote = fake_hg_repo
|
||||
|
||||
responses.add(
|
||||
responses.HEAD,
|
||||
"https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
|
||||
status=200,
|
||||
headers={"ETag": "123"},
|
||||
)
|
||||
|
||||
responses.add(
|
||||
responses.GET,
|
||||
"https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
|
||||
status=200,
|
||||
json={
|
||||
"file1": ["Firefox", "Menus"],
|
||||
"file2": ["Firefox", "General"],
|
||||
"file3": ["Core", "General"],
|
||||
},
|
||||
)
|
||||
|
||||
# Remove the mock DB generated by the mock_data fixture.
|
||||
os.remove("data/commits.json")
|
||||
|
||||
with open(os.path.join(local, ".hg-annotate-ignore-revs"), "w") as f:
|
||||
f.write("not_existing_hash\n")
|
||||
|
||||
add_file(hg, local, "file1", "1\n2\n3\n4\n5\n6\n7\n")
|
||||
commit(hg, date=datetime(1991, 4, 16, tzinfo=timezone.utc))
|
||||
hg.push(dest=bytes(remote, "ascii"))
|
||||
copy_pushlog_database(remote, local)
|
||||
|
||||
repository.download_commits(local, datetime(1970, 1, 1))
|
||||
commits = list(repository.get_commits())
|
||||
assert len(commits) == 0
|
||||
|
||||
add_file(hg, local, "file2", "1\n2\n3\n4\n5\n6\n7\n")
|
||||
revision2 = commit(hg, "Bug 123 - Prova. r=moz,rev2")
|
||||
hg.push(dest=bytes(remote, "ascii"))
|
||||
copy_pushlog_database(remote, local)
|
||||
|
||||
repository.download_commits(local, datetime(1970, 1, 1))
|
||||
commits = list(repository.get_commits())
|
||||
assert len(commits) == 1
|
||||
assert commits[0]["node"] == revision2
|
||||
|
||||
add_file(hg, local, "file3", "1\n2\n3\n4\n5\n6\n7\n")
|
||||
revision3 = commit(hg, "Bug 456 - Prova. r=moz")
|
||||
hg.push(dest=bytes(remote, "ascii"))
|
||||
copy_pushlog_database(remote, local)
|
||||
|
||||
repository.download_commits(local, datetime(1970, 1, 1))
|
||||
commits = list(repository.get_commits())
|
||||
assert len(commits) == 2
|
||||
assert commits[0]["node"] == revision2
|
||||
assert commits[1]["node"] == revision3
|
||||
|
||||
|
||||
def test_get_directories():
|
||||
assert repository.get_directories("") == []
|
||||
assert repository.get_directories("Makefile") == []
|
||||
|
|
Загрузка…
Ссылка в новой задаче