-
Notifications
You must be signed in to change notification settings - Fork 681
Adding public API test coverage for Aspire.Hosting.Python #5110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mitchdenny
merged 24 commits into
dotnet:main
from
Zombach:zombach/validate-arguments-of-public-methods#aspire-hosting-python
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c67cdf3
CA1062#Aspire.Hosting.Python
Zombach ad059e5
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach f3bd0d3
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach ec25311
Fix PR by feedback
Zombach 96efb2e
Merge branch 'zombach/validate-arguments-of-public-methods#aspire-hos…
Zombach 90a67ac
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 386bd9c
Remove Assert.Multiple by feedback
Zombach baf09c4
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach d038841
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 0ad4c44
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach fc8f9b2
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach f75eb99
builder replace to TestDistributedApplicationBuilder
Zombach 1179728
To expression body
Zombach 1961d80
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach a21b603
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 9fd8ab6
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 4466e5d
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach a54821a
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach be2c5c8
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 3616f3a
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach d2cd1b4
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 2420a46
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach 0fa62c5
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach ae319dc
Merge branch 'dotnet:main' into zombach/validate-arguments-of-public-…
Zombach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
270 changes: 270 additions & 0 deletions
270
tests/Aspire.Hosting.Python.Tests/PythonPublicApiTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,270 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Hosting.Utils; | ||
using Xunit; | ||
|
||
namespace Aspire.Hosting.Python.Tests; | ||
|
||
public class PythonPublicApiTests | ||
{ | ||
[Fact] | ||
public void CtorPythonProjectResourceShouldThrowWhenNameIsNull() | ||
{ | ||
string name = null!; | ||
const string executablePath = "/src/python"; | ||
const string projectDirectory = "/data/python"; | ||
|
||
var action = () => new PythonProjectResource(name, executablePath, projectDirectory); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void CtorPythonProjectResourceShouldThrowWhenExecutablePathIsNull() | ||
{ | ||
const string name = "Python"; | ||
string executablePath = null!; | ||
const string projectDirectory = "/data/python"; | ||
|
||
var action = () => new PythonProjectResource(name, executablePath, projectDirectory); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(executablePath), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void CtorPythonProjectResourceShouldThrowWhenProjectDirectoryIsNull() | ||
{ | ||
const string name = "Python"; | ||
const string executablePath = "/src/python"; | ||
string projectDirectory = null!; | ||
|
||
var action = () => new PythonProjectResource(name, executablePath, projectDirectory); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(projectDirectory), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectShouldThrowWhenBuilderIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = null!; | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
string[] scriptArgs = ["--traces"]; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
string name = null!; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
string[] scriptArgs = ["--traces"]; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectShouldThrowWhenProjectDirectoryIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
string projectDirectory = null!; | ||
const string scriptPath = "scripts"; | ||
string[] scriptArgs = ["--traces"]; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(projectDirectory), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectShouldThrowWhenScriptPathIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
string scriptPath = null!; | ||
string[] scriptArgs = ["--traces"]; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(scriptPath), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectShouldThrowWhenScriptArgsIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
string[] scriptArgs = null!; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(scriptArgs), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenBuilderIsNull() | ||
{ | ||
IDistributedApplicationBuilder builder = null!; | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
var virtualEnvironmentPath = ".venv"; | ||
string[] scriptArgs = ["--traces"]; ; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(builder), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenNameIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
string name = null!; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
const string virtualEnvironmentPath = ".venv"; | ||
string[] scriptArgs = ["--traces"]; ; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(name), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenProjectDirectoryIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
string projectDirectory = null!; | ||
const string scriptPath = "scripts"; | ||
const string virtualEnvironmentPath = ".venv"; | ||
string[] scriptArgs = ["--traces"]; ; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(projectDirectory), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenScriptPathIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
string scriptPath = null!; | ||
const string virtualEnvironmentPath = ".venv"; | ||
string[] scriptArgs = ["--traces"]; ; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(scriptPath), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenVirtualEnvironmentPathIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
string virtualEnvironmentPath = null!; | ||
string[] scriptArgs = ["--traces"]; ; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(virtualEnvironmentPath), exception.ParamName); | ||
} | ||
|
||
[Fact] | ||
public void AddPythonProjectWithVirtualEnvironmentPathShouldThrowWhenScriptArgsIsNull() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
const string name = "Python"; | ||
const string projectDirectory = "/src/python"; | ||
const string scriptPath = "scripts"; | ||
const string virtualEnvironmentPath = ".venv"; | ||
string[] scriptArgs = null!; | ||
|
||
var action = () => builder.AddPythonProject( | ||
name, | ||
projectDirectory, | ||
scriptPath, | ||
virtualEnvironmentPath, | ||
scriptArgs); | ||
|
||
var exception = Assert.Throws<ArgumentNullException>(action); | ||
Assert.Equal(nameof(scriptArgs), exception.ParamName); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.