1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/endpoints/api/test/test_trigger.py
Kenny Lee Sin Cheong 72f7c64ed6 chore: update werkzeug and related package versions (PROJQUAY-5098) (#1982)
* chore: update werkzeug and related package versions (PROJQUAY-5098)

Path converter related change reference: https://github.com/pallets/werkzeug/issues/2506

* Update query count
2023-09-12 11:51:09 -04:00

60 lines
1.6 KiB
Python

import json
from test.fixtures import *
import pytest
from data import model
from endpoints.api.test.shared import conduct_api_call
from endpoints.api.trigger import BuildTrigger
from endpoints.api.trigger_analyzer import is_parent
from endpoints.test.shared import client_with_identity
@pytest.mark.parametrize(
"context,dockerfile_path,expected",
[
("/", "/a/b", True),
("/a", "/a/b", True),
("/a/b", "/a/b", False),
("/a//", "/a/b", True),
("/a", "/a//b/c", True),
("/a//", "a/b", True),
("/a/b", "a/bc/d", False),
("/d", "/a/b", False),
("/a/b", "/a/b.c", False),
("/a/b", "/a/b/b.c", True),
("", "/a/b.c", False),
("/a/b", "", False),
("", "", False),
],
)
def test_super_user_build_endpoints(context, dockerfile_path, expected):
assert is_parent(context, dockerfile_path) == expected
def test_enabled_disabled_trigger(app):
trigger = model.build.list_build_triggers("devtable", "building")[0]
trigger.config = json.dumps({"hook_id": "someid"})
trigger.save()
params = {
"repository": "devtable/building",
"trigger_uuid": trigger.uuid,
}
body = {
"enabled": False,
}
with client_with_identity("devtable", app) as cl:
result = conduct_api_call(cl, BuildTrigger, "PUT", params, body, 200).json
assert not result["enabled"]
body = {
"enabled": True,
}
with client_with_identity("devtable", app) as cl:
result = conduct_api_call(cl, BuildTrigger, "PUT", params, body, 200).json
assert result["enabled"]