Skip to content

Commit

Permalink
Add test for lost sub-second when returning date. Needs updated PMGD.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishakha041 committed Apr 5, 2019
1 parent 05328e4 commit a43c982
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/cleandbs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rm -r jsongraph qhgraph simpleAdd_db simpleAddx10_db simpleUpdate_db entitycheck_db
rm -r jsongraph qhgraph simpleAdd_db simpleAddx10_db simpleUpdate_db entitycheck_db datatypecheck_db

rm -r tdb
rm -r dbs
Expand Down
68 changes: 68 additions & 0 deletions tests/server/DataTypeChecks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
{
"AddEntity":
{

"_ref": 1,
"class": "Patient",

"properties": {
"Email":"[email protected]",
"Age": 83,
"timestamp": 1544069566053,
"Birthday":{"_date":"1936-10-01T17:59:24.001-07:00"},
"Name":"Mark",
"fv": {"_blob":"Raghed----ghjhsglfhwa"}
}
}

},
{
"AddEntity":
{
"_ref": 2,
"class": "Patient",

"properties": {
"Email":"[email protected]",
"Age": 73,
"timestamp": 2544069566053,
"Birthday":{"_date":"1946-10-01T17:49:24.009010-07:00"},
"fv":{"_blob" :"Ahmad----ghjhsglfhwa"},
"Name": "Kai"

}
}

},
{
"AddConnection":
{
"ref1" : 1,
"ref2" : 2,
"class": "Married",
"properties":{
"since" : {"_date":"Sat Sep 1 19:59:24 PDT 1956"},
"fv": {"_blob":"----ghjhsglfhwa"},
"city" : "Boston",
"location" : "residence"
}
}

},
{
"FindEntity" : {
"class" : "Patient",
"constraints": {
"Age": ["<", 100 ]
},
"results": {
"list":["Name","Birthday"],
"sort" : {
"key" : "Age",
"order" : "descending"
}
}
}
}
]
10 changes: 10 additions & 0 deletions tests/server/config-datatype-tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// VDMS Config File
// This is the run-time config file
// Sets database paths and other parameters
{
// Network
"port": 55555,

// Database paths
"pmgd_path": "datatypecheck_db"
}
43 changes: 43 additions & 0 deletions tests/server/json_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,46 @@ TEST(QueryHandler, EmptyResultCheck)
VDMSConfig::destroy();
PMGDQueryHandler::destroy();
}

TEST(QueryHandler, DataTypeChecks)
{
Json::Reader reader;
Json::StyledWriter writer;

std::ifstream ifile;
int fsize;
char * inBuf;
ifile.open("server/DataTypeChecks.json", std::ifstream::in);
ifile.seekg(0, std::ios::end);
fsize = (int)ifile.tellg();
ifile.seekg(0, std::ios::beg);
inBuf = new char[fsize];
ifile.read(inBuf, fsize);
std::string json_query = std::string(inBuf);
ifile.close();
delete[] inBuf;

VDMSConfig::init("server/config-datatype-tests.json");
PMGDQueryHandler::init();
QueryHandler::init();

QueryHandler qh_base;
QueryHandlerTester query_handler(qh_base);

VDMS::protobufs::queryMessage proto_query;
proto_query.set_json(json_query);
VDMS::protobufs::queryMessage response;

query_handler.pq(proto_query, response );

Json::Value parsed;
reader.parse(response.json().c_str(), parsed);

// std::cout << writer.write(parsed) << std::endl;
const Json::Value& query = parsed[3];
EXPECT_EQ(query["FindEntity"]["entities"][0]["Birthday"].asString(), "1936-10-01T17:59:24.001-07:00");
EXPECT_EQ(query["FindEntity"]["entities"][1]["Birthday"].asString(), "1946-10-01T17:49:24.009010-07:00");

VDMSConfig::destroy();
PMGDQueryHandler::destroy();
}

0 comments on commit a43c982

Please sign in to comment.