def test_login_success(self, monkeypatch): monkeypatch.setattr('treq_kerberos.post', fake_post_ok) koji = Connection('mykoji') result = yield koji.login() assert result is True assert koji.session_id == 12345678 assert koji.session_key == '1234-abcdefghijklmnopqrst'
def tasks(self, monkeypatch): # To create this fixture file: # cbs call listTasks --kwargs="{'opts': {'owner': 144, 'method': 'build', 'decode': True}}" --json-output > txkoji/tests/fixtures/calls/listTasks.json # NOQA: E501 monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') opts = {'owner': 144, 'method': 'build'} d = koji.listTasks(opts) return pytest_twisted.blockon(d)
def channels(self, monkeypatch): # To create this fixture file: # cbs call listChannels \ # --json-output > txkoji/tests/fixtures/calls/listChannels.json monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') d = koji.listChannels() return pytest_twisted.blockon(d)
def build(self, monkeypatch): # To create this fixture file: # cbs call getBuild 24284 \ # --json-output > txkoji/tests/fixtures/calls/getBuild.json monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') d = koji.getBuild(24284) return pytest_twisted.blockon(d)
def task(self, monkeypatch): # To create this fixture file: # cbs call getTaskInfo 291929 --kwargs="{'request': True}" \ # --json-output > txkoji/tests/fixtures/calls/getTaskInfo.json monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') d = koji.getTaskInfo(291929) return pytest_twisted.blockon(d)
def example(reactor): koji = Connection('fedora') #koji = Connection('cbs') # Attempt to log in result = yield koji.login() print('logged in: %s' % result) print('session-id: %s' % koji.session_id) user = yield koji.getLoggedInUser() print(user)
def example(reactor): koji = Connection('brew') # Fetch the five latest ceph builds # "order: -build_id" will list the newest (build timestamp) ones first. opts = {'limit': 5, 'order': '-build_id'} # set "state" to txkoji.build_states.RUNNING here to filter further. builds = yield koji.listBuilds('ceph', state=None, queryOpts=opts) # builds are Munch (dict-like) objects. for build in builds: print(build.nvr) print(build.state)
def test_authenticated_call(self, monkeypatch): monkeypatch.setattr('treq_kerberos.post', fake_post_ok) monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') yield koji.login() # cbs call getLoggedInUser \ # --json-output > txkoji/tests/fixtures/calls/getLoggedInUser.json user = yield koji.getLoggedInUser() expected = Munch(status=0, authtype=2, name='ktdreyer', usertype=0, krb_principal=None, id=144) assert user == expected
def example(reactor): url = 'https://cbs.centos.org/koji/buildinfo?buildID=21155' koji = Connection.connect_from_web(url) if not koji: raise ValueError('url %s is not a recognizable Koji URL' % url) data = yield koji.from_web(url) print(data)
def example(reactor): task_id = sys.argv[1] koji = Connection('brew') # Look up the task information: task = yield koji.getTaskInfo(task_id) if task.state == task_states.FREE: # we'll wrap task.estimate_completion in estimate_free() below: # est_complete = yield task.estimate_completion() est_complete = yield estimate_free(koji, task) log_est_complete(est_complete) elif task.state == task_states.OPEN: est_complete = yield task.estimate_completion() log_est_complete(est_complete) else: log_delta('final duration: %s', task.duration)
def run(self, client, channel, nick, message, action, match): profile = 'brew' # todo: make this configurable koji = Connection(profile) d = defer.succeed(koji) for callback in action.callbacks: d.addCallback(callback, match, client, channel, nick) d.addErrback(send_err, client, channel) raise ResponseNotReady
def test_average_build_durations(monkeypatch): monkeypatch.setattr('txkoji.connection.Proxy', FakeMulticallProxy) koji = Connection('mykoji') avg_durations = yield average_build_durations(koji, ['ceph-ansible']) expected_delta = timedelta(0, 143, 401978) assert list(avg_durations) == [expected_delta]
def koji(monkeypatch): monkeypatch.setattr('txkoji.connection.Proxy', FakeProxy) koji = Connection('mykoji') return koji
def example(reactor): koji = Connection('brew') # Compare two ceph build tasks: yield describe_task(koji, 18117489) # without 'make check' yield describe_task(koji, 18199887) # with 'make check'
def test_login_failure(self, monkeypatch): monkeypatch.setattr('treq_kerberos.post', fake_post_unauthorized) koji = Connection('mykoji') with pytest.raises(KojiLoginException): yield koji.login()
def example(reactor): koji = Connection('fedora') name = yield koji.cache.tag_name(197) # "rawhide" print('tag name: %s' % name)
from twisted.internet import defer from twisted.python.compat import StringType from txkoji import Connection # We currently only support parsing Brew's UMB messages. koji = Connection('brew') @defer.inlineCallbacks def populate_owner_name(instance): """ Assign an .owner_name to this task or build, using caching. :param instance: txkoji.Task or txkoji.Build instance """ # Not every message has an owner_name, see BREW-1640 # In fact tasks do *not*, so we should do this elsewhere. if hasattr(instance, 'owner_name'): defer.returnValue(None) if isinstance(instance.owner, StringType): instance.owner_name = instance.owner defer.returnValue(None) owner_id = getattr(instance, 'owner_id', instance.owner) name = yield instance.connection.cache.user_name(owner_id) instance.owner_name = name defer.returnValue(None) def shorten_fqdn(name): """ Shorten any system account FQDN for readability. """ if '.' in name: