1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-12 23:56:13 +01:00
github.com_openSUSE_osc/tests/test_build.py

34 lines
1.2 KiB
Python

import unittest
import osc.conf
from osc.build import check_trusted_projects
from osc.oscerr import UserAbort
class TestTrustedProjects(unittest.TestCase):
def setUp(self):
osc.conf.config = osc.conf.Options()
def test_name(self):
apiurl = "https://example.com"
osc.conf.config["apiurl"] = apiurl
osc.conf.config.setdefault("api_host_options", {}).setdefault(apiurl, {}).setdefault("trusted_prj", None)
osc.conf.config["api_host_options"][apiurl]["trusted_prj"] = []
self.assertRaises(UserAbort, check_trusted_projects, apiurl, ["foo"], interactive=False)
osc.conf.config["api_host_options"][apiurl]["trusted_prj"] = ["qwerty", "foo", "asdfg"]
check_trusted_projects(apiurl, ["foo"], interactive=False)
def test_glob(self):
apiurl = "https://example.com"
osc.conf.config["apiurl"] = apiurl
osc.conf.config.setdefault("api_host_options", {}).setdefault(apiurl, {}).setdefault("trusted_prj", None)
osc.conf.config["api_host_options"][apiurl]["trusted_prj"] = ["f*"]
check_trusted_projects(apiurl, ["foo"], interactive=False)
if __name__ == "__main__":
unittest.main()