@@ -11,6 +11,8 @@ type E2e {
1111 let skipModulePath: String! = fixtureRoot + "/skip/app"
1212 let generateModulePath: String! = fixtureRoot + "/generate/app"
1313 let depsModulePath: String! = fixtureRoot + "/deps/app"
14+ let configModulePath: String! = fixtureRoot + "/config/app"
15+ let configuredModulePath: String! = fixtureRoot + "/config/configured"
1416
1517 let generatedMarkerPath: String! = "sdk/src/dagger/client/gen.py"
1618 let generatedMarkerContents: String! = "Code generated by dagger."
@@ -222,4 +224,74 @@ type E2e {
222224
223225 null
224226 }
227+
228+ """
229+ config.get should reflect pyproject.toml and report unset values as null
230+ rather than guessing, and config.set should edit only pyproject.toml.
231+ """
232+ pub configCheck(ws: Workspace!): Void @check {
233+ let app = pythonSdk.mod(ws, path: configModulePath).config
234+ let configured = pythonSdk.mod(ws, path: configuredModulePath).config
235+
236+ let appValues = app.get
237+ assert(appValues.pythonVersion == "3.14", "default pythonVersion should read 3.14")
238+ assert(appValues.useUv == null, "useUv should be reported as unset, not guessed")
239+ assert(appValues.baseImage == null, "baseImage should be reported as unset")
240+
241+ let configuredValues = configured.get
242+ assert(configuredValues.pythonVersion == "3.12", "configured pythonVersion should read 3.12")
243+ assert(configuredValues.useUv == false, "configured useUv should read false")
244+ assert(configuredValues.baseImage == "python:3.12-slim", "configured baseImage should read the override")
245+
246+ let pyproj = configModulePath + "/pyproject.toml"
247+
248+ let py = app.set(pythonVersion: "3.13")
249+ assert(contains(py.modifiedPaths, pyproj), "set should modify pyproject.toml")
250+ assert(py.modifiedPaths.length == 1, "set modified more than pyproject.toml")
251+ assert(py.addedPaths.length == 0, "set should not add files")
252+ assertContains(py.after.file(pyproj).contents, ">=3.13", "set did not write the new python version")
253+ assertContains(py.after.file(pyproj).contents, "dagger-io", "set dropped unrelated keys")
254+
255+ let multi = app.set(pythonVersion: "3.13", useUv: false, baseImage: "python:3.13-slim")
256+ assert(multi.modifiedPaths.length == 1, "multi-value set modified more than pyproject.toml")
257+ assert(multi.addedPaths.length == 0, "multi-value set should not add files")
258+ assertContains(multi.after.file(pyproj).contents, ">=3.13", "multi-value set did not write python version")
259+ assertContains(multi.after.file(pyproj).contents, "use-uv = false", "multi-value set did not write use-uv")
260+ assertContains(multi.after.file(pyproj).contents, "python:3.13-slim", "multi-value set did not write base image")
261+
262+ let configuredPyproj = configuredModulePath + "/pyproject.toml"
263+ let partial = configured.set(pythonVersion: "3.13")
264+ assertContains(partial.after.file(configuredPyproj).contents, ">=3.13", "partial set did not update python version")
265+ assertContains(partial.after.file(configuredPyproj).contents, "use-uv = false", "omitting useUv should leave it untouched")
266+ assertContains(partial.after.file(configuredPyproj).contents, "python:3.12-slim", "omitting baseImage should leave it untouched")
267+
268+ null
269+ }
270+
271+ """
272+ Init flags should write configuration into the generated pyproject.toml, and
273+ defaults should leave it unconfigured.
274+ """
275+ pub initConfigCheck(ws: Workspace!): Void @check {
276+ let configuredPath = outputRoot + "/init-configured"
277+ let defaultPath = outputRoot + "/init-config-default"
278+
279+ let configured = pythonSdk.init(ws, name: "init-configured", path: configuredPath, pythonVersion: "3.13", useUv: false, baseImage: "python:3.13-slim")
280+ let pyproj = configuredPath + "/pyproject.toml"
281+ assertAdded(configured, pyproj)
282+ assert(configured.modifiedPaths.length == 0, "configured init should not modify existing files")
283+ assert(configured.removedPaths.length == 0, "configured init should not remove files")
284+ assertContains(configured.layer.file(pyproj).contents, ">=3.13", "init --python-version not written")
285+ assertContains(configured.layer.file(pyproj).contents, "use-uv = false", "init --use-uv=false not written")
286+ assertContains(configured.layer.file(pyproj).contents, "python:3.13-slim", "init --base-image not written")
287+ assertContains(configured.layer.file(pyproj).contents, "dagger-io", "init config dropped template data")
288+
289+ let default = pythonSdk.init(ws, name: "init-config-default", path: defaultPath)
290+ let defaultPyproj = defaultPath + "/pyproject.toml"
291+ assertContains(default.layer.file(defaultPyproj).contents, ">=3.14", "default init should keep the template python version")
292+ assertNotContains(default.layer.file(defaultPyproj).contents, "use-uv", "default init should not write use-uv")
293+ assertNotContains(default.layer.file(defaultPyproj).contents, "[tool.dagger]", "default init should not write a [tool.dagger] table")
294+
295+ null
296+ }
225297}
0 commit comments