1616
1717
1818def pytest_addoption (parser ):
19- """Add custom command line options for integration tests."""
2019 parser .addoption (
2120 "--run-integration" ,
2221 action = "store_true" ,
@@ -26,14 +25,12 @@ def pytest_addoption(parser):
2625
2726
2827def pytest_configure (config ):
29- """Register custom markers."""
3028 config .addinivalue_line (
3129 "markers" , "integration: mark test as integration test (requires API token)"
3230 )
3331
3432
3533def pytest_collection_modifyitems (config , items ):
36- """Skip integration tests unless --run-integration is passed."""
3734 if config .getoption ("--run-integration" ):
3835 return
3936
@@ -121,19 +118,27 @@ async def test_workspaces(
121118) -> AsyncGenerator [List [Workspace ], None ]:
122119 created_workspaces : List [Workspace ] = []
123120
124- for i in range (2 ):
125- workspace_name = f"{ TEST_WORKSPACE_PREFIX } -{ i + 1 } "
121+ workspace_configs = [
122+ {"name" : f"{ TEST_WORKSPACE_PREFIX } -1" , "git_url" : None },
123+ {
124+ "name" : f"{ TEST_WORKSPACE_PREFIX } -git" ,
125+ "git_url" : "https://github.com/octocat/Hello-World.git" ,
126+ },
127+ ]
128+
129+ for config in workspace_configs :
126130 payload = WorkspaceCreate (
127131 team_id = test_team_id ,
128- name = workspace_name ,
132+ name = config [ "name" ] ,
129133 plan_id = test_plan_id ,
134+ git_url = config ["git_url" ],
130135 )
131136 try :
132137 workspace = await session_sdk_client .workspaces .create (payload = payload )
133138 created_workspaces .append (workspace )
134139 log .info (f"Created test workspace: { workspace .name } (ID: { workspace .id } )" )
135140 except Exception as e :
136- log .error (f"Failed to create test workspace { workspace_name } : { e } " )
141+ log .error (f"Failed to create test workspace { config [ 'name' ] } : { e } " )
137142 for ws in created_workspaces :
138143 try :
139144 await ws .delete ()
@@ -155,3 +160,17 @@ async def test_workspaces(
155160@pytest .fixture (scope = "session" )
156161async def test_workspace (test_workspaces : List [Workspace ]) -> Workspace :
157162 return test_workspaces [0 ]
163+
164+
165+ @pytest .fixture (scope = "session" )
166+ def git_workspace_id (test_workspaces : List [Workspace ]) -> int :
167+ return test_workspaces [1 ].id
168+
169+
170+ @pytest .fixture
171+ async def workspace_with_git (
172+ sdk_client : CodesphereSDK , git_workspace_id : int
173+ ) -> Workspace :
174+ workspace = await sdk_client .workspaces .get (workspace_id = git_workspace_id )
175+ await workspace .wait_until_running (timeout = 120.0 )
176+ return workspace
0 commit comments