Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ static async Task Main()
{
var fetched = await collection.Query.FetchObjectByID(id: id2);
Console.WriteLine(
"Cat retrieved via gRPC matches: "
+ ((fetched?.Objects.First().ID ?? Guid.Empty) == id2)
"Cat retrieved via gRPC matches: " + ((fetched?.ID ?? Guid.Empty) == id2)
);
}

Expand Down
13 changes: 10 additions & 3 deletions src/Weaviate.Client.Tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ public LoggingHandler(Action<string> log)
_log = log;
}

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken
)
{
_log($"Request: {request.Method} {request.RequestUri}");

Expand All @@ -19,7 +22,11 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
_log($"Request Content: {requestContent}");

// Buffer the content so it can be read again.
request.Content = new StringContent(requestContent, System.Text.Encoding.UTF8, "application/json");
request.Content = new StringContent(
requestContent,
System.Text.Encoding.UTF8,
"application/json"
);
}

foreach (var header in request.Headers)
Expand All @@ -44,4 +51,4 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage

return response;
}
}
}
11 changes: 4 additions & 7 deletions src/Weaviate.Client.Tests/Integration/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,15 @@ public async Task ObjectCreation()

// Assert object exists
var retrieved = await collectionClient.Query.FetchObjectByID(id);
var objects = retrieved.Objects.ToList();

Assert.NotNull(retrieved);
Assert.Single(objects);
Assert.Equal(id, objects[0].ID);
Assert.Equal("TestObject", objects[0].Properties["name"]);
Assert.Equal("TestObject", objects[0].As<TestData>()?.Name);
Assert.Equal(id, retrieved.ID);
Assert.Equal("TestObject", retrieved.Properties["name"]);
Assert.Equal("TestObject", retrieved.As<TestData>()?.Name);

// Delete after usage
await collectionClient.Data.Delete(id);
retrieved = await collectionClient.Query.FetchObjectByID(id);
Assert.NotNull(retrieved.Objects);
Assert.Empty(retrieved.Objects);
Assert.Null(retrieved);
}
}
155 changes: 155 additions & 0 deletions src/Weaviate.Client.Tests/Integration/Datasets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,161 @@ namespace Weaviate.Client.Tests.Integration;

public partial class BasicTests
{
public class DatasetFilterArrayTypes : TheoryData<string>
{
public static Dictionary<string, (Filter, int[])> Cases = new()
{
["Test 1"] = (Filter.Property("texts").Like("*nana"), new int[] { 1 }),
["Test 2"] = (Filter.Property("texts").Equal("banana"), new int[] { 1 }),
["Test 3"] = (Filter.Property("ints").Equal(3), new int[] { 1 }),
["Test 4"] = (Filter.Property("ints").GreaterThanEqual(3), new int[] { 1, 2 }),
["Test 5"] = (Filter.Property("floats").Equal(3), new int[] { 1 }),
["Test 6"] = (Filter.Property("floats").LessThanEqual(3), new int[] { 0, 1 }),
};

public DatasetFilterArrayTypes()
: base(Cases.Keys) { }
}

// Define test constants
private static readonly DateTime NOW = DateTime.UtcNow;
private static readonly DateTime LATER = NOW.AddHours(1);
private static readonly DateTime MUCH_LATER = NOW.AddDays(1);
private static readonly Guid UUID1 = Guid.NewGuid();
private static readonly Guid UUID2 = Guid.NewGuid();
private static readonly Guid UUID3 = Guid.NewGuid();

public class DatasetFilterContains : TheoryData<string>
{
public static Dictionary<string, (Filter, int[])> Cases = new()
{
["ContainsAny ints 1,4"] = (
Filter.Property("ints").ContainsAny([1, 4]),
new int[] { 0, 3 }
),
["ContainsAny ints 1.0,4"] = (
Filter.Property("ints").ContainsAny([1.0, 4]),
new int[] { 0, 3 }
),
["ContainsAny ints 10"] = (Filter.Property("ints").ContainsAny([10]), new int[] { }),
["ContainsAny int 1"] = (Filter.Property("int").ContainsAny([1]), new int[] { 0, 1 }),
["ContainsAny text test"] = (
Filter.Property("text").ContainsAny(["test"]),
new int[] { 0, 1 }
),
["ContainsAny text real,deal"] = (
Filter.Property("text").ContainsAny(["real", "deal"]),
new int[] { 1, 2, 3 }
),
["ContainsAny texts test"] = (
Filter.Property("texts").ContainsAny(["test"]),
new int[] { 0, 1 }
),
["ContainsAny texts real,deal"] = (
Filter.Property("texts").ContainsAny(["real", "deal"]),
new int[] { 1, 2, 3 }
),
["ContainsAny float 2.0"] = (
Filter.Property("float").ContainsAny([2.0]),
new int[] { }
),
["ContainsAny float 2"] = (Filter.Property("float").ContainsAny([2]), new int[] { }),
["ContainsAny float 8"] = (Filter.Property("float").ContainsAny([8]), new int[] { 3 }),
["ContainsAny float 8.0"] = (
Filter.Property("float").ContainsAny([8.0]),
new int[] { 3 }
),
["ContainsAny floats 2.0"] = (
Filter.Property("floats").ContainsAny([2.0]),
new int[] { 0, 1 }
),
["ContainsAny floats 0.4,0.7"] = (
Filter.Property("floats").ContainsAny([0.4, 0.7]),
new int[] { 0, 1, 3 }
),
["ContainsAny floats 2"] = (
Filter.Property("floats").ContainsAny([2]),
new int[] { 0, 1 }
),
["ContainsAny bools true,false"] = (
Filter.Property("bools").ContainsAny([true, false]),
new int[] { 0, 1, 3 }
),
["ContainsAny bools false"] = (
Filter.Property("bools").ContainsAny([false]),
new int[] { 0, 1 }
),
["ContainsAny bool true"] = (
Filter.Property("bool").ContainsAny([true]),
new int[] { 0, 1, 3 }
),
["ContainsAll ints 1,4"] = (
Filter.Property("ints").ContainsAll([1, 4]),
new int[] { 0 }
),
["ContainsAll text real,test"] = (
Filter.Property("text").ContainsAll(["real", "test"]),
new int[] { 1 }
),
["ContainsAll texts real,test"] = (
Filter.Property("texts").ContainsAll(["real", "test"]),
new int[] { 1 }
),
["ContainsAll floats 0.7,2"] = (
Filter.Property("floats").ContainsAll([0.7, 2]),
new int[] { 1 }
),
["ContainsAll bools true,false"] = (
Filter.Property("bools").ContainsAll([true, false]),
new int[] { 0 }
),
["ContainsAll bool true,false"] = (
Filter.Property("bool").ContainsAll([true, false]),
new int[] { }
),
["ContainsAll bool true"] = (
Filter.Property("bool").ContainsAll([true]),
new int[] { 0, 1, 3 }
),
["ContainsAny dates now,much_later"] = (
Filter.Property("dates").ContainsAny([NOW, MUCH_LATER]),
new int[] { 0, 1, 3 }
),
["ContainsAny dates now"] = (
Filter.Property("dates").ContainsAny([NOW]),
new int[] { 0, 1 }
),
["Equal date now"] = (Filter.Property("date").Equal(NOW), new int[] { 0 }),
["GreaterThan date now"] = (
Filter.Property("date").GreaterThan(NOW),
new int[] { 1, 3 }
),
["ContainsAll uuids uuid2,uuid1"] = (
Filter.Property("uuids").ContainsAll([UUID2, UUID1]),
new int[] { 0, 3 }
),
["ContainsAny uuids uuid2,uuid1"] = (
Filter.Property("uuids").ContainsAny([UUID2, UUID1]),
new int[] { 0, 1, 3 }
),
["ContainsAny uuid uuid3"] = (
Filter.Property("uuid").ContainsAny([UUID3]),
new int[] { }
),
["ContainsAny uuid uuid1"] = (
Filter.Property("uuid").ContainsAny([UUID1]),
new int[] { 0 }
),
["ContainsAny _id uuid1,uuid3"] = (
Filter.Property("_id").ContainsAny([UUID1, UUID3]),
new int[] { 0, 2 }
),
};

public DatasetFilterContains()
: base(Cases.Keys) { }
}

public class DatasetRefCountFilter : TheoryData<string>
{
public static Dictionary<string, (Filter, int[])> Cases =>
Expand Down
Loading