You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
912 B

  1. from keycloak import urls_patterns
  2. def test_correctness_of_patterns():
  3. """Test that there are no duplicate url patterns."""
  4. # Test that the patterns are present
  5. urls = [x for x in dir(urls_patterns) if not x.startswith("__")]
  6. assert len(urls) >= 0
  7. # Test that all patterns start with URL_
  8. for url in urls:
  9. assert url.startswith("URL_"), f"The url pattern {url} does not begin with URL_"
  10. # Test that the patterns have unique names
  11. seen_urls = list()
  12. for url in urls:
  13. assert url not in seen_urls, f"The url pattern {url} is present twice."
  14. seen_urls.append(url)
  15. # Test that the pattern values are unique
  16. seen_url_values = list()
  17. for url in urls:
  18. url_value = urls_patterns.__dict__[url]
  19. assert url_value not in seen_url_values, f"The url {url} has a duplicate value {url_value}"
  20. seen_url_values.append(url_value)