Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaponte committed Mar 16, 2022
1 parent 58a97c6 commit fa627e2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion invisible_cities/database/download_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@ def test_create_table_sqlite(dbname, output_tmpdir):

connSqlite = sqlite3.connect(dbfile)
connMySql = pymysql.connect(host="neutrinos1.ific.uv.es",
user='nextreader',passwd='readonly', db=dbname)
user='nextreader',passwd='readonly', db=dbname)

cursorMySql = connMySql .cursor()
cursorSqlite = connSqlite.cursor()

for table in db.tables:
db.create_table_sqlite(cursorSqlite, cursorMySql, table)


@mark.parametrize('dbname', db.dbnames)
def test_table_assignment(dbname):
for name in db.common_tables:
assert name in db.table_dict[dbname]

for name in db.extended.get(dbname, ()):
assert name in db.table_dict[dbname]


@mark.parametrize('dbname', db.dbnames)
def test_tables_exist(dbname):
connMySql = pymysql.connect(host="neutrinos1.ific.uv.es",
user='nextreader',passwd='readonly', db=dbname)

cursor = connMySql.cursor()
cursor.execute("Show tables;")
available = cursor.fetchall()

for name in db.table_dict[dbname]:
assert (name,) in available


0 comments on commit fa627e2

Please sign in to comment.