diff options
Diffstat (limited to 'tests/artifactcache/config.py')
-rw-r--r-- | tests/artifactcache/config.py | 64 |
1 files changed, 15 insertions, 49 deletions
diff --git a/tests/artifactcache/config.py b/tests/artifactcache/config.py index d2df0fd79..204bc7398 100644 --- a/tests/artifactcache/config.py +++ b/tests/artifactcache/config.py @@ -25,12 +25,8 @@ cache3 = RemoteSpec(url="https://example.com/cache3", push=False) cache4 = RemoteSpec(url="https://example.com/cache4", push=False) cache5 = RemoteSpec(url="https://example.com/cache5", push=False) cache6 = RemoteSpec(url="https://example.com/cache6", push=True, type=RemoteType.ALL) -cache7 = RemoteSpec( - url="https://index.example.com/cache1", push=True, type=RemoteType.INDEX -) -cache8 = RemoteSpec( - url="https://storage.example.com/cache1", push=True, type=RemoteType.STORAGE -) +cache7 = RemoteSpec(url="https://index.example.com/cache1", push=True, type=RemoteType.INDEX) +cache8 = RemoteSpec(url="https://storage.example.com/cache1", push=True, type=RemoteType.STORAGE) # Generate cache configuration fragments for the user config and project config files. @@ -57,8 +53,7 @@ def configure_remote_caches(override_caches, project_caches=None, user_caches=No } elif len(user_caches) > 1: user_config["artifacts"] = [ - {"url": cache.url, "push": cache.push, "type": type_strings[cache.type]} - for cache in user_caches + {"url": cache.url, "push": cache.push, "type": type_strings[cache.type]} for cache in user_caches ] if len(override_caches) == 1: @@ -75,11 +70,7 @@ def configure_remote_caches(override_caches, project_caches=None, user_caches=No user_config["projects"] = { "test": { "artifacts": [ - { - "url": cache.url, - "push": cache.push, - "type": type_strings[cache.type], - } + {"url": cache.url, "push": cache.push, "type": type_strings[cache.type],} for cache in override_caches ] } @@ -101,11 +92,7 @@ def configure_remote_caches(override_caches, project_caches=None, user_caches=No project_config.update( { "artifacts": [ - { - "url": cache.url, - "push": cache.push, - "type": type_strings[cache.type], - } + {"url": cache.url, "push": cache.push, "type": type_strings[cache.type],} for cache in project_caches ] } @@ -123,25 +110,15 @@ def configure_remote_caches(override_caches, project_caches=None, user_caches=No pytest.param([], [], [], id="empty-config"), pytest.param([], [], [cache1, cache2], id="user-config"), pytest.param([], [cache1, cache2], [cache3], id="project-config"), - pytest.param( - [cache1], [cache2], [cache3], id="project-override-in-user-config" - ), - pytest.param( - [cache1, cache2], [cache3, cache4], [cache5, cache6], id="list-order" - ), - pytest.param( - [cache1, cache2, cache1], [cache2], [cache2, cache1], id="duplicates" - ), + pytest.param([cache1], [cache2], [cache3], id="project-override-in-user-config"), + pytest.param([cache1, cache2], [cache3, cache4], [cache5, cache6], id="list-order"), + pytest.param([cache1, cache2, cache1], [cache2], [cache2, cache1], id="duplicates"), pytest.param([cache7, cache8], [], [cache1], id="split-caches"), ], ) -def test_artifact_cache_precedence( - tmpdir, override_caches, project_caches, user_caches -): +def test_artifact_cache_precedence(tmpdir, override_caches, project_caches, user_caches): # Produce a fake user and project config with the cache configuration. - user_config, project_config = configure_remote_caches( - override_caches, project_caches, user_caches - ) + user_config, project_config = configure_remote_caches(override_caches, project_caches, user_caches) project_config["name"] = "test" user_config_file = str(tmpdir.join("buildstream.conf")) @@ -156,14 +133,10 @@ def test_artifact_cache_precedence( project.ensure_fully_loaded() # Use the helper from the artifactcache module to parse our configuration. - parsed_cache_specs = ArtifactCache._configured_remote_cache_specs( - context, project - ) + parsed_cache_specs = ArtifactCache._configured_remote_cache_specs(context, project) # Verify that it was correctly read. - expected_cache_specs = list( - _deduplicate(itertools.chain(override_caches, project_caches, user_caches)) - ) + expected_cache_specs = list(_deduplicate(itertools.chain(override_caches, project_caches, user_caches))) assert parsed_cache_specs == expected_cache_specs @@ -172,19 +145,14 @@ def test_artifact_cache_precedence( # instead of an unhandled exception. @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize( - "config_key, config_value", - [("client-cert", "client.crt"), ("client-key", "client.key")], + "config_key, config_value", [("client-cert", "client.crt"), ("client-key", "client.key")], ) def test_missing_certs(cli, datafiles, config_key, config_value): project = os.path.join(datafiles.dirname, datafiles.basename, "missing-certs") project_conf = { "name": "test", - "artifacts": { - "url": "https://cache.example.com:12345", - "push": "true", - config_key: config_value, - }, + "artifacts": {"url": "https://cache.example.com:12345", "push": "true", config_key: config_value,}, } project_conf_file = os.path.join(project, "project.conf") _yaml.roundtrip_dump(project_conf, project_conf_file) @@ -215,9 +183,7 @@ def test_only_one(cli, datafiles, override_caches, project_caches, user_caches): project = os.path.join(datafiles.dirname, datafiles.basename, "only-one") # Produce a fake user and project config with the cache configuration. - user_config, project_config = configure_remote_caches( - override_caches, project_caches, user_caches - ) + user_config, project_config = configure_remote_caches(override_caches, project_caches, user_caches) project_config["name"] = "test" cli.configure(user_config) |