From 7f3a6a312ef74ac5e3628744b686a2073cc99818 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 10 Dec 2019 20:57:33 +0000 Subject: [PATCH] --- DataFilter/DataFilterFilteringLists.cs | 133 ++++++++++++++----------- FormCustom/FormCustom.cs | 48 --------- util.cs | 22 ++-- 3 files changed, 89 insertions(+), 114 deletions(-) diff --git a/DataFilter/DataFilterFilteringLists.cs b/DataFilter/DataFilterFilteringLists.cs index f513f5b..0e3761a 100644 --- a/DataFilter/DataFilterFilteringLists.cs +++ b/DataFilter/DataFilterFilteringLists.cs @@ -19,6 +19,10 @@ namespace raven_integration This is the supertest to always confirm the filtering code is working as expected. +BUGBUG: Server takes into account user's time zone offset when filtering lists by date range but here the local test runner just uses the windows system offset instead of the defined offset in the User account at the server +Fix: Since seeder uses same time zone for all users it generates then can simply fetch one single users' tz offset and use that centerally to calculate a relative now and relative today +same as the server does but in a central location here for all tests to use. + */ public class DataFilterFilteringLists @@ -104,7 +108,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -206,7 +210,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -308,7 +312,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -409,7 +413,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -511,7 +515,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -613,7 +617,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -715,7 +719,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -818,7 +822,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -920,7 +924,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1022,7 +1026,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1125,7 +1129,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1229,7 +1233,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1332,7 +1336,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1438,7 +1442,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1510,6 +1514,15 @@ namespace raven_integration public async void DateTokenNextMonthFilterWorks() { + //SERVER thinks midnight UTC is 7am our time on January 1st 2020 + //TEST thinks midnight UTC is 8am our time on January 1st 2020 + //THIS is because the User time zone offset is taken into account *at the server* but it isn't here + //Here, it assumes the correct offset was set in the test data + //At the server it assumes nothing + //Fix? Possibly this code here in the unit tests needs to adjust the times the same way based on the user account + + var vv = Util.MyTest; + var WidgetNameStart = "DateTokenNextMonthFilterWorks"; long IncludedWidgetId = 0; @@ -1517,12 +1530,16 @@ namespace raven_integration //CREATE TEST WIDGETS - //included widget + //included widget (Date range is within NEXT month from the 2nd at midnight to the second at 1am) dynamic w = new JObject(); w.name = Util.Uniquify(WidgetNameStart); w.notes = "blah"; w.customFields = Util.WidgetRequiredCustomFieldsJsonString(); //Put it right at midnight next month to ensure boundaries are respected + + //Note: this test is failing in December 2019, possibly due to year boundary? + + //Note, due to daylight saving time this test can fail by one hour on the boundary //as noted in March 2019 //w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).ToUniversalTime(); @@ -1534,7 +1551,7 @@ namespace raven_integration Util.ValidateDataReturnResponseOk(a); IncludedWidgetId = a.ObjectResponse["data"]["id"].Value(); - //Excluded widget + //Excluded widget (Date range is within NEXT month from one second **before** the 1st to one hour later) w.name = Util.Uniquify(WidgetNameStart); //First day of next month minus 1 second w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).AddSeconds(-1).ToUniversalTime(); @@ -1548,7 +1565,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1653,7 +1670,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1759,7 +1776,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1862,7 +1879,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -1966,7 +1983,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2072,7 +2089,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2178,7 +2195,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2281,7 +2298,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2384,7 +2401,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2506,7 +2523,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2623,7 +2640,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2738,7 +2755,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2854,7 +2871,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -2983,7 +3000,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3108,7 +3125,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3230,7 +3247,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3353,7 +3370,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3476,7 +3493,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3599,7 +3616,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3722,7 +3739,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3845,7 +3862,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -3967,7 +3984,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -4089,7 +4106,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -4211,7 +4228,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -4333,7 +4350,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -4456,7 +4473,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -4577,7 +4594,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("Test INT DataFilter"); - + d["public"] = true; d.listKey = "widget"; @@ -4679,7 +4696,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("Test INT DataFilter"); - + d["public"] = true; d.listKey = "widget"; @@ -4781,7 +4798,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("IntegerOpGreaterThanOrEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -4885,7 +4902,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("IntegerOpLessThanFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -4988,7 +5005,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("IntegerOpLessThanOrEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5092,7 +5109,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("IntegerNotEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5222,7 +5239,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("Test BOOL DataFilter"); - + d["public"] = true; d.listKey = "widget"; @@ -5350,7 +5367,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("Test BOOL DataFilter"); - + d["public"] = true; d.listKey = "widget"; @@ -5464,7 +5481,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalOpEqualityFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5566,7 +5583,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalOpGreaterThanFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5668,7 +5685,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalOpGreaterThanOrEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5772,7 +5789,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalOpLessThanFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5875,7 +5892,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalOpLessThanOrEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -5979,7 +5996,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify("DecimalNotEqualToFilterWorks"); - + d["public"] = true; d.listKey = "widget"; @@ -6123,7 +6140,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; @@ -6265,7 +6282,7 @@ namespace raven_integration //CREATE FILTER dynamic d = new JObject(); d.name = Util.Uniquify(WidgetRunNameStart); - + d["public"] = true; d.listKey = "widget"; diff --git a/FormCustom/FormCustom.cs b/FormCustom/FormCustom.cs index 83fe11c..a415dea 100644 --- a/FormCustom/FormCustom.cs +++ b/FormCustom/FormCustom.cs @@ -24,54 +24,6 @@ namespace raven_integration dynamic d = new JObject(); d.formkey = "user"; - /* - - -As sending from client now with fail: -{ -"formKey":"widget", -"concurrencyToken":3798757, -"template":[ -{"fld":"WidgetName","required":true,"hide":false},{"fld":"WidgetStartDate","required":true,"hide":false},{"fld":"WidgetEndDate","required":true,"hide":false},{"fld":"WidgetNotes","required":true,"hide":false},{"fld":"WidgetCustom1","required":false,"type":"datetime"},{"fld":"WidgetCustom2","required":true,"type":"text"},{"fld":"WidgetCustom3","required":false,"type":"number"},{"fld":"WidgetCustom4","required":false,"type":"bool"},{"fld":"WidgetCustom5","required":false,"type":"currency"},{"fld":"WidgetCustom6","required":false,"type":"date"},{"fld":"WidgetCustom7","required":false,"type":"time"} -] -} - -//As it appears in this unit test to string -"{\r\n \"formkey\": \"user\",\r\n \"template\": \"[\\r\\n {\\r\\n \\\"fld\\\": \\\"UserCustom1\\\",\\r\\n \\\"hide\\\": false,\\r\\n \\\"required\\\": true,\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n }, -\\r\\n {\\r\\n \\\"fld\\\": \\\"UserNotes\\\",\\r\\n \\\"required\\\": true\\r\\n },\\r\\n -{\\r\\n \\\"fld\\\": \\\"UserCustom2\\\",\\r\\n \\\"hide\\\": true,\\r\\n \\\"required\\\": false,\\r\\n \\\"type\\\": \\\"bool\\\"\\r\\n }\\r\\n]\", -\r\n \"concurrencyToken\": 3802346\r\n}" - -//cleaned up unit test string from immediately above here -"{"formkey":"user","template":"[{"fld":"UserCustom1","hide":false,"required":true,"type":"text"}, -{"fld":"UserNotes","required":true}, -{"fld":"UserCustom2","hide":true,"required":false,"type":"bool"}]", -"concurrencyToken":3802346}" - - -//As it fetches off the server now -{ - "data": { - "id": 1, - "concurrencyToken": 3798757, - "formKey": "widget", - "template": "[{\"fld\":\"WidgetNotes\",\"required\":true},{\"fld\":\"WidgetCustom1\",\"required\":false,\"type\":\"datetime\"},{\"fld\":\"WidgetCustom2\",\"required\":true,\"type\":\"text\"}, - {\"fld\":\"WidgetCustom3\",\"required\":false,\"type\":\"number\"},{\"fld\":\"WidgetCustom4\",\"required\":false,\"type\":\"bool\"},{\"fld\":\"WidgetCustom5\",\"required\":false,\"type\":\"currency\"}, - {\"fld\":\"WidgetCustom6\",\"required\":false,\"type\":\"date\"},{\"fld\":\"WidgetCustom7\",\"required\":false,\"type\":\"time\"}]" - } -} - -OK, it appears the quotes need to be escaped for some reason?, this works: -{"concurrencyToken": 3802346, - "formKey": "user", - "template": "[{\"fld\":\"UserCustom1\",\"hide\":false,\"required\":true,\"type\":\"text\"},{\"fld\":\"UserNotes\",\"required\":true},{\"fld\":\"UserCustom2\",\"hide\":true,\"required\":false,\"type\":\"bool\"}]"} - - - - - - */ - dynamic dtemplate = new JArray(); dynamic dt = new JObject(); diff --git a/util.cs b/util.cs index 617f740..7ed3b3e 100644 --- a/util.cs +++ b/util.cs @@ -10,6 +10,17 @@ namespace raven_integration { public static class Util { + //####################################################################################################### + public static string API_BASE_URL = "http://localhost:7575/api/v8/"; + //public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/"; + public static string TEST_DATA_FOLDER = @"..\..\..\testdata\"; + + public const decimal TIME_ZONE_ADJUSTMENT = -7; + //####################################################################################################### + + + + public const string OpEquality = "="; public const string OpGreaterThan = ">"; public const string OpGreaterThanOrEqualTo = ">="; @@ -24,10 +35,7 @@ namespace raven_integration private static HttpClient client { get; } = new HttpClient(); - public static string API_BASE_URL = "http://localhost:7575/api/v8/"; - //public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/"; - - public static string TEST_DATA_FOLDER = @"..\..\..\testdata\"; + public static ConcurrentDictionary authDict = new ConcurrentDictionary();//10,32 @@ -41,8 +49,6 @@ namespace raven_integration public async static Task GetTokenAsync(string login, string password = null) { - // Console.WriteLine($"GetTokenAsync:{login}"); - //System.Diagnostics.Trace.WriteLine($"GetTokenAsync:{login}"); if (password == null) password = login; @@ -141,12 +147,12 @@ namespace raven_integration public async static Task GetNonApiPageAsync(string route) { init(); - var requestMessage = new HttpRequestMessage(HttpMethod.Get, CleanNonApiRoute(route)); + var requestMessage = new HttpRequestMessage(HttpMethod.Get, CleanNonApiRoute(route)); HttpResponseMessage response = await client.SendAsync(requestMessage); var responseAsString = await response.Content.ReadAsStringAsync(); return new ApiTextResponse() { HttpResponse = response, TextResponse = responseAsString }; } - +