forked from dtcenter/METdataio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature 318 add db for testing (dtcenter#326)
* 318: add mariadb gh actions * 318: Update tests to use actual db * Update conftest with fixtures to access and update test database mv_test * Add fixure to clean database (drop/recreate) * Add fixture to access test data in METreformat * Add example test of met_db_load.py * 318: remove METdbLoad tests from sonarqube gh workflow. * 318: fix test, pass tmpdir as list.
- Loading branch information
1 parent
59696a8
commit bb65007
Showing
10 changed files
with
219 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<load_spec> | ||
<connection> | ||
<management_system>mysql</management_system> | ||
<host>localhost:3306</host> | ||
<database>mv_load_test</database> | ||
<user>user</user> | ||
<password>user_pwd</password> | ||
</connection> | ||
<connection> | ||
<management_system>mysql</management_system> | ||
<host>localhost:3306</host> | ||
<database>mv_test</database> | ||
<user>root</user> | ||
<password>root_password</password> | ||
</connection> | ||
|
||
<folder_tmpl>/path-to/test_data/load_data/load/met_data/point_stat/2011070812/metprd</folder_tmpl> | ||
<verbose>true</verbose> | ||
<insert_size>1</insert_size> | ||
<stat_header_db_check>true</stat_header_db_check> | ||
<mode_header_db_check>false</mode_header_db_check> | ||
<mtd_header_db_check>false</mtd_header_db_check> | ||
<drop_indexes>false</drop_indexes> | ||
<apply_indexes>false</apply_indexes> | ||
<load_stat>true</load_stat> | ||
<load_mode>true</load_mode> | ||
<load_mtd>true</load_mtd> | ||
<load_mpr>true</load_mpr> | ||
<load_orank>true</load_orank> | ||
<load_val> | ||
<field name="met_tool"> | ||
<val>point_stat</val> | ||
</field> | ||
</load_val> | ||
<group>Testing</group> | ||
<description>testing DB load</description> | ||
</load_spec> | ||
<folder_tmpl>/METdataio/METreformat/test/data/point_stat</folder_tmpl> | ||
<verbose>true</verbose> | ||
<insert_size>1</insert_size> | ||
<stat_header_db_check>true</stat_header_db_check> | ||
<mode_header_db_check>false</mode_header_db_check> | ||
<mtd_header_db_check>false</mtd_header_db_check> | ||
<drop_indexes>false</drop_indexes> | ||
<apply_indexes>false</apply_indexes> | ||
<load_stat>true</load_stat> | ||
<load_mode>true</load_mode> | ||
<load_mtd>true</load_mtd> | ||
<load_mpr>true</load_mpr> | ||
<load_orank>true</load_orank> | ||
<load_val> | ||
<field name="met_tool"> | ||
<val>point_stat</val> | ||
</field> | ||
</load_val> | ||
<group>Testing</group> | ||
<description>testing DB load</description> | ||
</load_spec> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import argparse | ||
from METdbLoad.conftest import TOP_DIR | ||
from METdbLoad.ush.met_db_load import main as load_main | ||
from METdbLoad.ush.run_sql import RunSql | ||
|
||
def test_met_db_load(emptyDB, get_xml_test_file, testRunSql, tmp_path): | ||
|
||
# TODO: parameterize this test data | ||
test_data = { | ||
"xmlfile": str(get_xml_test_file), | ||
"index": True, | ||
"tmpdir": [str(tmp_path)], | ||
} | ||
test_args = argparse.Namespace() | ||
for k,v in test_data.items(): | ||
setattr(test_args, k, v) | ||
|
||
load_main(test_args) | ||
|
||
# Check the correct number of rows written | ||
testRunSql.cur.execute("SELECT * FROM line_data_cts") | ||
cts_data = testRunSql.cur.fetchall() | ||
|
||
assert len(cts_data) == 24 | ||
|
||
#TODO: check all the other metrics and some values. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.