b6be7a351f
* First pass * First pass adding service registraiton * Finished up service registration * Json exception * Moved to the right place * Fixed tests * Added some missing docs strings * Reflecting Gergo's specklepy changes * Correct the DI registration * Readme * No warn beta packages * Format * renamed misleading variable * Fixed lock files * Disable SQLite for automate
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using GraphQL;
|
|
using Speckle.Sdk.Api;
|
|
using Speckle.Sdk.Models;
|
|
|
|
namespace Speckle.Automate.Sdk.Integration;
|
|
|
|
public static class TestAutomateUtils
|
|
{
|
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness")]
|
|
public static string RandomString(int length)
|
|
{
|
|
Random rand = new();
|
|
const string POOL = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
IEnumerable<char> chars = Enumerable.Range(0, length).Select(_ => POOL[rand.Next(0, POOL.Length)]);
|
|
return new string(chars.ToArray());
|
|
}
|
|
|
|
public static Base TestObject()
|
|
{
|
|
Base rootObject = new() { ["foo"] = "bar" };
|
|
return rootObject;
|
|
}
|
|
|
|
public static async Task RegisterNewAutomation(
|
|
string projectId,
|
|
string modelId,
|
|
IClient speckleClient,
|
|
string automationId,
|
|
string automationName,
|
|
string automationRevisionId
|
|
)
|
|
{
|
|
//language=graphql
|
|
GraphQLRequest query = new(
|
|
query: """
|
|
mutation CreateAutomation(
|
|
$projectId: String!
|
|
$modelId: String!
|
|
$automationName: String!
|
|
$automationId: String!
|
|
$automationRevisionId: String!
|
|
) {
|
|
automationMutations {
|
|
create(
|
|
input: {
|
|
projectId: $projectId
|
|
modelId: $modelId
|
|
automationName: $automationName
|
|
automationId: $automationId
|
|
automationRevisionId: $automationRevisionId
|
|
}
|
|
)
|
|
}
|
|
}
|
|
""",
|
|
variables: new
|
|
{
|
|
projectId,
|
|
modelId,
|
|
automationName,
|
|
automationId,
|
|
automationRevisionId,
|
|
}
|
|
);
|
|
|
|
await speckleClient.ExecuteGraphQLRequest<object>(query);
|
|
}
|
|
}
|