refactor complete
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from backend.src.core.logger import belief_scope, logger
|
||||
from src.core.logger import belief_scope, logger
|
||||
|
||||
|
||||
# [DEF:test_belief_scope_logs_entry_action_exit:Function]
|
||||
|
||||
@@ -1,62 +1,23 @@
|
||||
import pytest
|
||||
from superset_tool.models import SupersetConfig
|
||||
from superset_tool.utils.logger import belief_scope
|
||||
from src.core.config_models import Environment
|
||||
from src.core.logger import belief_scope
|
||||
|
||||
# [DEF:test_superset_config_url_normalization:Function]
|
||||
# @PURPOSE: Tests that SupersetConfig correctly normalizes the base URL.
|
||||
# @PRE: SupersetConfig class is available.
|
||||
# @POST: URL normalization is verified.
|
||||
def test_superset_config_url_normalization():
|
||||
with belief_scope("test_superset_config_url_normalization"):
|
||||
auth = {
|
||||
"provider": "db",
|
||||
"username": "admin",
|
||||
"password": "password",
|
||||
"refresh": "token"
|
||||
}
|
||||
|
||||
# Test with /api/v1 already present
|
||||
config = SupersetConfig(
|
||||
env="dev",
|
||||
base_url="http://localhost:8088/api/v1",
|
||||
auth=auth
|
||||
# [DEF:test_environment_model:Function]
|
||||
# @PURPOSE: Tests that Environment model correctly stores values.
|
||||
# @PRE: Environment class is available.
|
||||
# @POST: Values are verified.
|
||||
def test_environment_model():
|
||||
with belief_scope("test_environment_model"):
|
||||
env = Environment(
|
||||
id="test-id",
|
||||
name="test-env",
|
||||
url="http://localhost:8088/api/v1",
|
||||
username="admin",
|
||||
password="password"
|
||||
)
|
||||
assert config.base_url == "http://localhost:8088/api/v1"
|
||||
|
||||
# Test without /api/v1
|
||||
config = SupersetConfig(
|
||||
env="dev",
|
||||
base_url="http://localhost:8088",
|
||||
auth=auth
|
||||
)
|
||||
assert config.base_url == "http://localhost:8088/api/v1"
|
||||
|
||||
# Test with trailing slash
|
||||
config = SupersetConfig(
|
||||
env="dev",
|
||||
base_url="http://localhost:8088/",
|
||||
auth=auth
|
||||
)
|
||||
assert config.base_url == "http://localhost:8088/api/v1"
|
||||
assert env.id == "test-id"
|
||||
assert env.name == "test-env"
|
||||
assert env.url == "http://localhost:8088/api/v1"
|
||||
# [/DEF:test_superset_config_url_normalization:Function]
|
||||
|
||||
# [DEF:test_superset_config_invalid_url:Function]
|
||||
# @PURPOSE: Tests that SupersetConfig raises ValueError for invalid URLs.
|
||||
# @PRE: SupersetConfig class is available.
|
||||
# @POST: ValueError is raised for invalid URLs.
|
||||
def test_superset_config_invalid_url():
|
||||
with belief_scope("test_superset_config_invalid_url"):
|
||||
auth = {
|
||||
"provider": "db",
|
||||
"username": "admin",
|
||||
"password": "password",
|
||||
"refresh": "token"
|
||||
}
|
||||
|
||||
with pytest.raises(ValueError, match="Must start with http:// or https://"):
|
||||
SupersetConfig(
|
||||
env="dev",
|
||||
base_url="localhost:8088",
|
||||
auth=auth
|
||||
)
|
||||
# [/DEF:test_superset_config_invalid_url:Function]
|
||||
|
||||
Reference in New Issue
Block a user