feat: add tests for admin checks and error handling
All checks were successful
CI / lint-and-test (push) Successful in 23s
All checks were successful
CI / lint-and-test (push) Successful in 23s
- Introduced new tests for the `is_admin_async` function to verify correct behavior based on user roles. - Added tests for error handling in the `error_handler` to ensure exceptions are logged and do not propagate. - Enhanced test coverage for configuration settings by adding a test for parsing admin phone numbers from environment variables. - Updated the `.cursorrules` file to include the use of a virtual environment for better dependency management.
This commit is contained in:
@@ -38,6 +38,13 @@ def test_can_access_miniapp_denied(monkeypatch):
|
||||
assert config.can_access_miniapp("") is False
|
||||
|
||||
|
||||
def test_settings_from_env_parse_admin_phones_adds_normalized(monkeypatch):
|
||||
"""Settings.from_env() parses ADMIN_PHONES and adds normalized phone to admin_phones."""
|
||||
monkeypatch.setenv("ADMIN_PHONES", "+7 900 123-45-67")
|
||||
settings = config.Settings.from_env()
|
||||
assert settings.admin_phones == {"79001234567"}
|
||||
|
||||
|
||||
def test_normalize_phone():
|
||||
"""Phone is normalized to digits only."""
|
||||
assert config.normalize_phone("+7 900 123-45-67") == "79001234567"
|
||||
|
||||
Reference in New Issue
Block a user