Пример #1
0
    def test_staging_or_production(self, monkeypatch):
        '''Client should be correctly created when requested staging in config or not'''
        monkeypatch.setattr(config, '_config', None)
        conf = config.get_config()
        assert conf.bodhi_staging is False
        bu = bodhi_utils.BodhiUtils()
        prod_url = bu.client.base_url

        conf.bodhi_staging = True
        bu_stg = bodhi_utils.BodhiUtils()
        stg_url = bu_stg.client.base_url

        assert prod_url != stg_url
        assert prod_url == bodhi.client.bindings.BASE_URL
        assert stg_url == bodhi.client.bindings.STG_BASE_URL
Пример #2
0
    def test_query_non_existing_update(self, monkeypatch):
        '''Test query for non-existing update'''
        ref_query_answer = {'updates': []}
        stub_bodhi = mock.Mock(**{'query.return_value': ref_query_answer})
        bodhi = bodhi_utils.BodhiUtils(client=stub_bodhi)
        update = bodhi.get_update(self.ref_update_id)

        assert update is None
Пример #3
0
    def test_query_existing_update(self):
        '''Test query for existing update'''
        ref_query_answer = {'updates': [self.ref_update]}
        stub_bodhi = mock.Mock(**{'query.return_value': ref_query_answer})
        bodhi = bodhi_utils.BodhiUtils(client=stub_bodhi)
        update = bodhi.get_update(self.ref_update_id)

        assert update == self.ref_update
Пример #4
0
    def __init__(self, bodhi_api=None, koji_session=None):

        if bodhi_api:
            self.bodhi_api = bodhi_api
        else:
            self.bodhi_api = bodhi.BodhiUtils()

        if koji_session:
            self.koji_session = koji_session
        else:
            self.koji_session = KojiClient()
Пример #5
0
 def setup(self, monkeypatch):
     '''Run this before every test invocation'''
     self.client = mock.Mock()
     self.bodhi = bodhi_utils.BodhiUtils(self.client)
     self.client.query = mock.Mock(side_effect=self.mock_query)