68 строки
2.0 KiB
Python
68 строки
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
from mozci.util.hgmo import HGMO
|
|
|
|
|
|
def test_hgmo_cache():
|
|
# HGMO.create() uses a cache.
|
|
h1 = HGMO.create("abcdef", "autoland")
|
|
h2 = HGMO.create("abcdef", "autoland")
|
|
assert h1 == h2
|
|
|
|
# Instantiating directly ignores the cache.
|
|
h1 = HGMO("abcdef", "autoland")
|
|
h2 = HGMO("abcdef", "autoland")
|
|
assert h1 != h2
|
|
|
|
|
|
def test_hgmo_backouts(responses):
|
|
responses.add(
|
|
responses.GET,
|
|
"https://hg.mozilla.org/integration/autoland/json-automationrelevance/abcdef",
|
|
json={"changesets": [{"backsoutnodes": []}]},
|
|
status=200,
|
|
)
|
|
|
|
responses.add(
|
|
responses.GET,
|
|
"https://hg.mozilla.org/integration/autoland/json-automationrelevance/abcdef",
|
|
json={"changesets": [{"node": "789", "backsoutnodes": [{"node": "123456"}]}]},
|
|
status=200,
|
|
)
|
|
|
|
responses.add(
|
|
responses.GET,
|
|
"https://hg.mozilla.org/integration/autoland/json-automationrelevance/abcdef",
|
|
json={
|
|
"changesets": [
|
|
{"node": "789", "backsoutnodes": [{"node": "123456"}]},
|
|
{"node": "jkl", "backsoutnodes": [{"node": "asd"}, {"node": "fgh"}]},
|
|
]
|
|
},
|
|
status=200,
|
|
)
|
|
|
|
h = HGMO("abcdef")
|
|
assert h.backouts == {}
|
|
assert h.changesets[0]["backsoutnodes"] == []
|
|
|
|
h = HGMO("abcdef")
|
|
assert h.backouts == {"789": ["123456"]}
|
|
assert h.changesets[0]["backsoutnodes"] == [{"node": "123456"}]
|
|
|
|
h = HGMO("abcdef")
|
|
assert h.backouts == {"789": ["123456"], "jkl": ["asd", "fgh"]}
|
|
assert h.changesets[0]["backsoutnodes"] == [{"node": "123456"}]
|
|
assert h.changesets[1]["backsoutnodes"] == [{"node": "asd"}, {"node": "fgh"}]
|
|
|
|
|
|
def test_hgmo_json_data(responses):
|
|
responses.add(
|
|
responses.GET,
|
|
"https://hg.mozilla.org/integration/autoland/rev/abcdef?style=json",
|
|
json={"backedoutby": "123456"},
|
|
status=200,
|
|
)
|
|
|
|
h = HGMO("abcdef")
|
|
assert h.get("backedoutby") == "123456"
|