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.

27 lines
937 B

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