Test unsafe patterns in dbschema
This commit is contained in:
parent
1f4a5643db
commit
699a8be721
1 changed files with 16 additions and 5 deletions
|
@ -1,9 +1,5 @@
|
||||||
import os
|
|
||||||
import cStringIO as StringIO
|
import cStringIO as StringIO
|
||||||
|
|
||||||
from Config import config
|
|
||||||
from Db import Db
|
|
||||||
|
|
||||||
|
|
||||||
class TestDb:
|
class TestDb:
|
||||||
def testCheckTables(self, db):
|
def testCheckTables(self, db):
|
||||||
|
@ -69,6 +65,21 @@ class TestDb:
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
assert db.updateJson(db.db_dir + "data.json", f) == True
|
assert db.updateJson(db.db_dir + "data.json", f) is True
|
||||||
assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 1
|
assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 1
|
||||||
assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 1
|
assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 1
|
||||||
|
|
||||||
|
def testUnsafePattern(self, db):
|
||||||
|
db.schema["maps"] = {"[A-Za-z.]*": db.schema["maps"]["data.json"]} # Only repetition of . supported
|
||||||
|
f = StringIO.StringIO()
|
||||||
|
f.write("""
|
||||||
|
{
|
||||||
|
"test": [
|
||||||
|
{"test_id": 1, "title": "Test 1 title", "extra col": "Ignore it"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
f.seek(0)
|
||||||
|
assert db.updateJson(db.db_dir + "data.json", f) is False
|
||||||
|
assert db.execute("SELECT COUNT(*) AS num FROM test_importfilter").fetchone()["num"] == 0
|
||||||
|
assert db.execute("SELECT COUNT(*) AS num FROM test").fetchone()["num"] == 0
|
||||||
|
|
Loading…
Reference in a new issue