4648
This commit is contained in:
330
Tags/TagOps.cs
330
Tags/TagOps.cs
@@ -1,165 +1,165 @@
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class TagOps
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void TagListsWork()
|
||||
{
|
||||
|
||||
var TestName = "TagListsWork";
|
||||
var WidgetRunNameStart = Util.Uniquify(TestName);
|
||||
var TagNameStart = Util.Uniquify("crud-tag-test-") + "-";//ensure this run gets it's own unique tags
|
||||
TagNameStart = TagNameStart.Replace(" ", "");
|
||||
|
||||
List<string> InitialTagsList = new List<string>();
|
||||
InitialTagsList.Add(TagNameStart + "red");
|
||||
InitialTagsList.Add(TagNameStart + "orange");
|
||||
InitialTagsList.Add(TagNameStart + "yellow");
|
||||
InitialTagsList.Add(TagNameStart + "green");
|
||||
InitialTagsList.Add(TagNameStart + "blue");
|
||||
InitialTagsList.Add(TagNameStart + "indigo");
|
||||
InitialTagsList.Add(TagNameStart + "violet");
|
||||
|
||||
List<string> UpdateTagsList = new List<string>();
|
||||
//Newly added tags
|
||||
UpdateTagsList.Add(TagNameStart + "crimson");
|
||||
UpdateTagsList.Add(TagNameStart + "amber");
|
||||
UpdateTagsList.Add(TagNameStart + "saffron");
|
||||
UpdateTagsList.Add(TagNameStart + "emerald");
|
||||
UpdateTagsList.Add(TagNameStart + "azure");
|
||||
UpdateTagsList.Add(TagNameStart + "cobalt");
|
||||
UpdateTagsList.Add(TagNameStart + "magenta");
|
||||
|
||||
//maintains these tags
|
||||
UpdateTagsList.Add(TagNameStart + "red");
|
||||
UpdateTagsList.Add(TagNameStart + "blue");
|
||||
|
||||
//Removes these tags by omission
|
||||
//orange, yellow, green, indigo, violet
|
||||
|
||||
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||
w.notes = "blah";
|
||||
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
w.usertype = 1;
|
||||
//Tags
|
||||
dynamic InitialTags = new JArray();
|
||||
foreach (string s in InitialTagsList)
|
||||
{
|
||||
InitialTags.Add(s);
|
||||
}
|
||||
w.tags = InitialTags;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long WidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
uint Concurrency = a.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
w = a.ObjectResponse["data"];
|
||||
|
||||
//validate the repository LIST ROUTE of tags contains the ones above
|
||||
a = await Util.GetAsync($"tag-list/list?query={TagNameStart}", await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(7);
|
||||
|
||||
|
||||
//UPDATE Tags
|
||||
dynamic UpdateTags = new JArray();
|
||||
|
||||
//Adds these tags
|
||||
foreach (string s in UpdateTagsList)
|
||||
{
|
||||
UpdateTags.Add(s);
|
||||
}
|
||||
//update Widget and put to server
|
||||
w.concurrency = Concurrency;
|
||||
w.tags = UpdateTags;
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
|
||||
//Verify the tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/list?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(9);
|
||||
|
||||
//Verify the CLOUD LIST AND REF COUNT of tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/cloudlist?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(9);
|
||||
a.ObjectResponse["data"][0]["refCount"].Value<long>().Should().Be(1);
|
||||
|
||||
//DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("widget/" + WidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
//Verify the tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/list?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test bulk tag bad params
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void BulkBadParamsShouldFail()
|
||||
{
|
||||
|
||||
dynamic d = new JArray();
|
||||
// d.Add(1);
|
||||
// d.Add(2);
|
||||
// d.Add(3);
|
||||
|
||||
ApiResponse a = await Util.PostAsync("tag-list/bulk-add/33/my new tag", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Test bulk tag
|
||||
// /// </summary>
|
||||
// [Fact]
|
||||
// public async void BulkTagDriver()
|
||||
// {
|
||||
|
||||
// dynamic d = new JArray();
|
||||
// d.Add(1);
|
||||
// d.Add(2);
|
||||
|
||||
|
||||
// ApiResponse a = await Util.PostAsync("tag-list/bulk-add/2/my new tag", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-add-any/2/bulk-add-this-tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-remove/2/happy%20new%20tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-remove-any/2/red
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-replace/2/bulk-add-this-tag?toTag=bulk-update-this-tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-replace-any/2/bulk-update-this-tag?toTag=bulk-replace-this-tag-any
|
||||
// ;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class TagOps
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task TagListsWork()
|
||||
{
|
||||
|
||||
var TestName = "TagListsWork";
|
||||
var WidgetRunNameStart = Util.Uniquify(TestName);
|
||||
var TagNameStart = Util.Uniquify("crud-tag-test-") + "-";//ensure this run gets it's own unique tags
|
||||
TagNameStart = TagNameStart.Replace(" ", "");
|
||||
|
||||
List<string> InitialTagsList = new List<string>();
|
||||
InitialTagsList.Add(TagNameStart + "red");
|
||||
InitialTagsList.Add(TagNameStart + "orange");
|
||||
InitialTagsList.Add(TagNameStart + "yellow");
|
||||
InitialTagsList.Add(TagNameStart + "green");
|
||||
InitialTagsList.Add(TagNameStart + "blue");
|
||||
InitialTagsList.Add(TagNameStart + "indigo");
|
||||
InitialTagsList.Add(TagNameStart + "violet");
|
||||
|
||||
List<string> UpdateTagsList = new List<string>();
|
||||
//Newly added tags
|
||||
UpdateTagsList.Add(TagNameStart + "crimson");
|
||||
UpdateTagsList.Add(TagNameStart + "amber");
|
||||
UpdateTagsList.Add(TagNameStart + "saffron");
|
||||
UpdateTagsList.Add(TagNameStart + "emerald");
|
||||
UpdateTagsList.Add(TagNameStart + "azure");
|
||||
UpdateTagsList.Add(TagNameStart + "cobalt");
|
||||
UpdateTagsList.Add(TagNameStart + "magenta");
|
||||
|
||||
//maintains these tags
|
||||
UpdateTagsList.Add(TagNameStart + "red");
|
||||
UpdateTagsList.Add(TagNameStart + "blue");
|
||||
|
||||
//Removes these tags by omission
|
||||
//orange, yellow, green, indigo, violet
|
||||
|
||||
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||
w.notes = "blah";
|
||||
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
w.usertype = 1;
|
||||
//Tags
|
||||
dynamic InitialTags = new JArray();
|
||||
foreach (string s in InitialTagsList)
|
||||
{
|
||||
InitialTags.Add(s);
|
||||
}
|
||||
w.tags = InitialTags;
|
||||
|
||||
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long WidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
uint Concurrency = a.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
w = a.ObjectResponse["data"];
|
||||
|
||||
//validate the repository LIST ROUTE of tags contains the ones above
|
||||
a = await Util.GetAsync($"tag-list/list?query={TagNameStart}", await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(7);
|
||||
|
||||
|
||||
//UPDATE Tags
|
||||
dynamic UpdateTags = new JArray();
|
||||
|
||||
//Adds these tags
|
||||
foreach (string s in UpdateTagsList)
|
||||
{
|
||||
UpdateTags.Add(s);
|
||||
}
|
||||
//update Widget and put to server
|
||||
w.concurrency = Concurrency;
|
||||
w.tags = UpdateTags;
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
|
||||
//Verify the tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/list?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(9);
|
||||
|
||||
//Verify the CLOUD LIST AND REF COUNT of tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/cloudlist?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(9);
|
||||
a.ObjectResponse["data"][0]["refCount"].Value<long>().Should().Be(1);
|
||||
|
||||
//DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("widget/" + WidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
//Verify the tags collection remaining
|
||||
a = await Util.GetAsync($"tag-list/list?query=" + TagNameStart, await Util.GetTokenAsync("superuser", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test bulk tag bad params
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task BulkBadParamsShouldFail()
|
||||
{
|
||||
|
||||
dynamic d = new JArray();
|
||||
// d.Add(1);
|
||||
// d.Add(2);
|
||||
// d.Add(3);
|
||||
|
||||
ApiResponse a = await Util.PostAsync("tag-list/bulk-add/33/my new tag", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Test bulk tag
|
||||
// /// </summary>
|
||||
// [Fact]
|
||||
// public async Task BulkTagDriver()
|
||||
// {
|
||||
|
||||
// dynamic d = new JArray();
|
||||
// d.Add(1);
|
||||
// d.Add(2);
|
||||
|
||||
|
||||
// ApiResponse a = await Util.PostAsync("tag-list/bulk-add/2/my new tag", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-add-any/2/bulk-add-this-tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-remove/2/happy%20new%20tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-remove-any/2/red
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-replace/2/bulk-add-this-tag?toTag=bulk-update-this-tag
|
||||
// //http://localhost:7575/api/v8/tag-list/bulk-replace-any/2/bulk-update-this-tag?toTag=bulk-replace-this-tag-any
|
||||
// ;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
|
||||
Reference in New Issue
Block a user