MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / testUpdateJson

Method testUpdateJson

src/Test/TestDb.py:110–122  ·  view source on GitHub ↗
(self, db)

Source from the content-addressed store, hash-verified

108
109
110 def testUpdateJson(self, db):
111 f = io.BytesIO()
112 f.write("""
113 {
114 "test": [
115 {"test_id": 1, "title": "Test 1 title", "extra col": "Ignore it"}
116 ]
117 }
118 """.encode())
119 f.seek(0)
120 assert db.updateJson(db.db_dir + "data.json", f) is True
121 assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 1
122 assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 1
123
124 def testUnsafePattern(self, db):
125 db.schema["maps"] = {"[A-Za-z.]*": db.schema["maps"]["data.json"]} # Only repetition of . supported

Callers

nothing calls this directly

Calls 4

updateJsonMethod · 0.80
writeMethod · 0.45
seekMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected