diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-10-09 14:53:58 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-10-09 14:53:58 +0300 |
commit | f31490125c56c7e1dfc2bb782a8af0167957dc1c (patch) | |
tree | d7536c455329f88755a93c27d1a570741f52d06d /tests/Settings | |
parent | 24f95a9cabffdf5af1a9aa4524d5efcfd82c7fec (diff) |
Add test to check if profile ID's are unique
CURA-7763
Diffstat (limited to 'tests/Settings')
-rw-r--r-- | tests/Settings/TestProfiles.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/Settings/TestProfiles.py b/tests/Settings/TestProfiles.py index fba57c5eea..7a9c3fed93 100644 --- a/tests/Settings/TestProfiles.py +++ b/tests/Settings/TestProfiles.py @@ -61,6 +61,25 @@ variant_filepaths = collectAllVariants() intent_filepaths = collectAllIntents() +def test_uniqueID(): + """Check if the ID's from the qualities, variants & intents are unique.""" + + all_paths = quality_filepaths + variant_filepaths + intent_filepaths + all_ids = {} + for path in all_paths: + profile_id = os.path.basename(path) + profile_id = profile_id.replace(".inst.cfg", "") + if profile_id not in all_ids: + all_ids[profile_id] = [] + all_ids[profile_id].append(path) + + duplicated_ids_with_paths = {profile_id: paths for profile_id, paths in all_ids.items() if len(paths) > 1} + if len(duplicated_ids_with_paths.keys()) == 0: + return # No issues! + + assert False, "Duplicate profile ID's were detected! Ensure that every profile ID is unique: %s" % duplicated_ids_with_paths + + @pytest.mark.parametrize("file_name", quality_filepaths) def test_validateQualityProfiles(file_name): """Attempt to load all the quality profiles.""" @@ -93,6 +112,7 @@ def test_validateQualityProfiles(file_name): print("Got an Exception while reading the file [%s]: %s" % (file_name, e)) assert False + @pytest.mark.parametrize("file_name", intent_filepaths) def test_validateIntentProfiles(file_name): try: @@ -115,6 +135,7 @@ def test_validateIntentProfiles(file_name): # File can't be read, header sections missing, whatever the case, this shouldn't happen! assert False, "Got an exception while reading the file {file_name}: {err}".format(file_name = file_name, err = str(e)) + @pytest.mark.parametrize("file_name", variant_filepaths) def test_validateVariantProfiles(file_name): """Attempt to load all the variant profiles.""" @@ -143,6 +164,7 @@ def test_validateVariantProfiles(file_name): print("Got an Exception while reading the file [%s]: %s" % (file_name, e)) assert False + @pytest.mark.parametrize("file_name", quality_filepaths + variant_filepaths + intent_filepaths) def test_versionUpToDate(file_name): try: |