def test_discover(self): org = 'quay.io/cogniteev' truncated_config = StringIO() config = load_config(self.CONFIG_FILE) config['organizations'][org]['repositories'] = None save_config(config, truncated_config) truncated_config.seek(0, 0) discover_command(['cogniteev'], truncated_config, interactive=False) config = load_config(self.CONFIG_FILE) tags = config.get('organizations', {})\ .get('quay.io/cogniteev', {})\ .get('repositories', {})\ .get('docido-contrib-crawlers', {})\ .get('on_build', {})\ .get('tags', {}) self.assertEqual(len(tags), 1) latest_trigger = tags.get('latest') self.assertEqual(len(latest_trigger), 1) github_repo = 'quay.io/cogniteev/docido-pull-crawler-github' assertCountEqual( self, latest_trigger.get(github_repo), [ dict(trigger_uuid="dcb1e958-9fdb-4e9b-9856-4d52771b3df9", ref="refs/heads/develop"), dict(trigger_uuid="567da7a3-0373-4cf2-8480-58a18b8dbe47", ref="refs/tags/v1.1"), ] )
def test_unlink(self): config_path = osp.join(osp.dirname(__file__), 'test_cli.yaml') q = QuayCon(load_config(config_path)) org = 'cogniteev' (q.org(QUAYIO_REGISTRY, org) or {}).pop('repositories', None) q.unlink('{}/{}'.format(QUAYIO_REGISTRY, org)) self.assertEqual( q.config, { 'organizations': { 'quay.io/cogniteev': { 'token': '0123456789ABCDEF' }, 'https://index.docker.io/v1/_': { 'repositories': { 'python': { } } } } } )
def _check_dumb_config(self, *args, **kwargs): self.assertEqual( load_config(*args, **kwargs), self._config_dict(), )
def test_load_from_unknown_path(self): load_config('/path/to/unknown/file.yml')
def test_load_empty_config(self): self.assertEqual(load_config(), {})