File size: 981 Bytes
b67c03f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest

from src.config import user_bucket_source
from src.jobs import normalize_target_space


def test_normalize_target_space_with_slug():
    assert normalize_target_space(username="alice", target_slug="my-space", run_id="run-123") == "alice/my-space"


def test_normalize_target_space_rejects_other_namespace():
    with pytest.raises(ValueError):
        normalize_target_space(username="alice", target_slug="bob/my-space", run_id="run-123")


def test_normalize_target_space_accepts_own_namespace():
    assert normalize_target_space(username="alice", target_slug="alice/my-space", run_id="run-123") == "alice/my-space"


def test_user_bucket_source_uses_signed_in_namespace():
    assert user_bucket_source(username="alice", bucket_name="space-factory-runs") == "alice/space-factory-runs"


def test_user_bucket_source_rejects_owner_name_bucket():
    with pytest.raises(ValueError):
        user_bucket_source(username="alice", bucket_name="bob/space-factory-runs")