Skip to content

Commit

Permalink
MongoDB: Improve test case about different types of timestamp fields
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Sep 2, 2024
1 parent 71e3aa7 commit 54937b1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/io/mongodb/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_version():
"name": "foobar",
"active": True,
"created": dateutil.parser.parse("2020-06-19T15:03:53.727Z"),
"timestamp": bson.datetime_ms.DatetimeMS(1455141600000),
},
}
DOCUMENT_OUT = {
Expand All @@ -48,6 +49,7 @@ def test_version():
"name": "foobar",
"active": True,
"created": 1592579033000,
"timestamp": 1455141600000,
},
}

Expand Down Expand Up @@ -106,10 +108,27 @@ def test_mongodb_load_table_real(caplog, cratedb, mongodb):
)
assert result.exit_code == 0

# Verify data in target database.
# Verify metadata in target database.
assert cratedb.database.table_exists("testdrive.demo") is True
assert cratedb.database.refresh_table("testdrive.demo") is True
assert cratedb.database.count_records("testdrive.demo") == 1

# Verify content in target database.
results = cratedb.database.run_sql("SELECT * FROM testdrive.demo", records=True)
assert results[0] == DOCUMENT_OUT

# Verify schema in target database.
results = cratedb.database.run_sql("SHOW CREATE TABLE testdrive.demo")
assert (
"""
CREATE TABLE IF NOT EXISTS "testdrive"."demo" (
"__id" TEXT,
"id" TEXT,
"value" OBJECT(DYNAMIC) AS (
"name" TEXT,
"active" BOOLEAN,
"created" TIMESTAMP WITH TIME ZONE,
"timestamp" TIMESTAMP WITH TIME ZONE
)
)""".lstrip()
) in results[0][0]

0 comments on commit 54937b1

Please sign in to comment.