- Add slug field with uniqueness constraint to Organization - Use python-slugify to generate slug from name and import that in migration - Require name in all /rename and org creation requests - Auto-generate slug for new org with no slug or when /rename is called w/o a slug - Auto-generate slug for 'default-org' based on name - Add /api/orgs/slugs GET endpoint to return all slugs in use - tests: extend backend test-requirements.txt from requirements to allow testing slugify - tests: move get_redis_crawl_stats() to avoid extra dependency in utils
		
			
				
	
	
		
			20 lines
		
	
	
		
			566 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			566 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """utils tests"""
 | |
| import pytest
 | |
| 
 | |
| from btrixcloud.utils import slug_from_name
 | |
| 
 | |
| 
 | |
| @pytest.mark.parametrize(
 | |
|     "name,expected_slug",
 | |
|     [
 | |
|         ("Default org", "default-org"),
 | |
|         ("User's org", "users-org"),
 | |
|         ("User's @ org", "users-org"),
 | |
|         ("Org with åccénted charactêrs", "org-with-accented-characters"),
 | |
|         ("Org with åccénted! charactêrs@!", "org-with-accented-characters"),
 | |
|         ("cATs! 🐈🐈⬛", "cats"),
 | |
|     ],
 | |
| )
 | |
| def test_slug_from_name(name: str, expected_slug: str):
 | |
|     assert slug_from_name(name) == expected_slug
 |