Commit ae04291a authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Skip builtin rules

parent 4955ca21
......@@ -45,7 +45,7 @@ def test_main_help():
def test_main_minimal():
with tempdir():
gen_test_data(10, 100, 'data.tsv')
main.main('out.tsv data.tsv'.split())
main.main('-nb out.tsv data.tsv'.split())
out = pd.read_csv('out.tsv', delimiter='\t')
data = pd.read_csv('data.tsv', delimiter='\t')
......@@ -58,7 +58,7 @@ def test_main_minimal():
def test_main_minimal_lowMemory():
with tempdir():
gen_test_data(10, 100, 'data.tsv')
main.main('-n -n -lm out.tsv data.tsv'.split())
main.main('-nb -lm out.tsv data.tsv'.split())
out = pd.read_csv('out.tsv', delimiter='\t')
data = pd.read_csv('data.tsv', delimiter='\t')
......@@ -76,12 +76,12 @@ def test_main_overwrite():
f.write('abc')
with pytest.raises(SystemExit):
main.main('out.tsv data.tsv'.split())
main.main('-nb out.tsv data.tsv'.split())
with open('out.tsv', 'rt') as f:
assert f.read() == 'abc'
main.main('-ow out.tsv data.tsv'.split())
main.main('-nb -ow out.tsv data.tsv'.split())
out = pd.read_csv('out.tsv', delimiter='\t')
data = pd.read_csv('data.tsv', delimiter='\t')
......@@ -110,7 +110,7 @@ def test_main_pluginfile():
f.write(plugin)
main.main(
'-p plugin.py -sp -gc replace_with_nines out.tsv data.tsv'.split())
'-nb -p plugin.py -sp -gc replace_with_nines out.tsv data.tsv'.split())
out = pd.read_csv('out.tsv', delimiter='\t')
......@@ -144,6 +144,7 @@ def test_main_configfile():
cfg = tw.dedent("""
overwrite
no_builtins
""").strip()
with tempdir():
......@@ -215,7 +216,7 @@ def test_main_variables():
f.write('3\n')
# Single ID and range
main.main('-v varfile.txt -v 4 -v 5 -v 6:7 out.tsv data.tsv'.split())
main.main('-nb -v varfile.txt -v 4 -v 5 -v 6:7 out.tsv data.tsv'.split())
data = pd.read_csv('data.tsv', delimiter='\t').set_index('eid')
out = pd.read_csv('out.tsv', delimiter='\t').set_index('eid')
......@@ -226,7 +227,7 @@ def test_main_variables():
assert np.all(out.loc[:, :] == data.loc[:, expcols])
# Single ID and range and list
main.main('-ow -v varfile.txt -v 8:10 -v 4,5,7 -v 1 '
main.main('-nb -ow -v varfile.txt -v 8:10 -v 4,5,7 -v 1 '
'out.tsv data.tsv'.split())
data = pd.read_csv('data.tsv', delimiter='\t').set_index('eid')
......@@ -246,7 +247,7 @@ def test_main_variables():
f.write('3\n')
f.write('4\n')
main.main('-ow -v varfile.txt -v 3 -v 4 -v 5 -v 5 -v 6:7 '
main.main('-nb -ow -v varfile.txt -v 3 -v 4 -v 5 -v 5 -v 6:7 '
'out.tsv data.tsv'.split())
data = pd.read_csv('data.tsv', delimiter='\t').set_index('eid')
......@@ -407,7 +408,7 @@ def test_main_visits():
tables = loadtables.loadDefaultTables(['data.tsv'])[:3]
dt, _ = importing.importData(['data.tsv'], *tables)
base = '-p plugin.py -ow '
base = '-p plugin.py -ow -nb '
main.main((base + '-vi first out.tsv data.tsv').split())
gotfirst = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
......@@ -628,14 +629,14 @@ def test_main_column_names():
with tempdir():
gen_test_data(10, 100, 'data.tsv')
main.main(shlex.split('-oi subby -cp "{variable}-woo" out.tsv data.tsv'))
main.main(shlex.split('-nb -oi subby -cp "{variable}-woo" out.tsv data.tsv'))
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
exp = ['{}-woo'.format(i) for i in range(1, 11)]
assert np.all(got.columns == exp)
assert got.index.name == 'subby'
main.main(shlex.split(
'-ow -rc 1-0.0 woopy -cp "{name}" out.tsv data.tsv'))
'-nb -ow -rc 1-0.0 woopy -cp "{name}" out.tsv data.tsv'))
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
exp = ['{}-0.0'.format(i) for i in range(1, 11)]
exp[0] = 'woopy'
......@@ -644,12 +645,12 @@ def test_main_column_names():
# non-standard input column names
names = ['{}-0.0'.format(i) for i in range(1, 10)] + ['woopy']
gen_test_data(10, 100, 'data.tsv', names=names)
main.main(shlex.split('-ow out.tsv data.tsv'))
main.main(shlex.split('-nb -ow out.tsv data.tsv'))
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
assert sorted(got.columns) == sorted(names)
gen_test_data(10, 100, 'data.tsv', names=names)
main.main(shlex.split('-ow -cp "{name}-{visit}" out.tsv data.tsv'))
main.main(shlex.split('-nb -ow -cp "{name}-{visit}" out.tsv data.tsv'))
exp = ['{}-0.0-0'.format(i) for i in range(1, 10)] + ['woopy-0']
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
assert sorted(got.columns) == sorted(exp)
......@@ -689,7 +690,7 @@ def test_main_clean():
f.write( '4\tInteger\t\t\t\t\t\t\t\t\n')
gen_test_data(10, 100, 'data.tsv')
main.main('-p plugin.py '
main.main('-nb -p plugin.py '
'-vf variables.tsv '
'-cl 1 test_clean1 '
'-cl 2 test_clean2 '
......@@ -705,7 +706,7 @@ def test_main_clean():
assert np.all(( 4 * data['3-0.0']) == got['3-0.0'])
assert np.all(( 6 * data['4-0.0']) == got['4-0.0'])
main.main('-ow '
main.main('-nb -ow '
'-cl 4 test_clean4 '
'-gc test_clean1 '
'out.tsv data.tsv'.split())
......@@ -716,7 +717,7 @@ def test_main_clean():
assert np.all(( 2 * data['3-0.0']) == got['3-0.0'])
assert np.all((10 * data['4-0.0']) == got['4-0.0'])
main.main('-ow -vf variables.tsv '
main.main('-nb -ow -vf variables.tsv '
'-gc test_clean4 '
'out.tsv data.tsv'.split())
data = pd.read_csv('data.tsv', delimiter='\t', index_col=0)
......@@ -728,14 +729,14 @@ def test_main_clean():
with open('variables.tsv', 'wt') as f:
f.write('ID\tType\tDescription\tDataCoding\tNAValues\tRawLevels\tNewLevels\tParentValues\tChildValues\tClean\n')
f.write( '4\tInteger\t\t\t\t\t\t\t\ttest_clean4\n')
main.main('-ow -vf variables.tsv '
main.main('-nb -ow -vf variables.tsv '
'-cl 4 test_clean3 '
'out.tsv data.tsv'.split())
data = pd.read_csv('data.tsv', delimiter='\t', index_col=0)
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
assert np.all(( 4 * data.loc[:, '4-0.0']) == got.loc[:, '4-0.0'])
main.main(shlex.split('-ow -vf variables.tsv '
main.main(shlex.split('-nb -ow -vf variables.tsv '
'-cl 4 \'\' '
'out.tsv data.tsv'))
data = pd.read_csv('data.tsv', delimiter='\t', index_col=0)
......@@ -831,7 +832,7 @@ def test_main_variable_ordering():
cat4 = ['{}-0.0'.format(v) for v in range(16, 21)]
catunkn = ['{}-0.0'.format(v) for v in range(2, 21, 2)]
argbase = ' -q -vf variables.tsv -cf categories.tsv -ow out.tsv data.tsv'
argbase = ' -q -nb -vf variables.tsv -cf categories.tsv -ow out.tsv data.tsv'
main.main(('-v 1 -v 2 -v 3' + argbase).split())
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
......@@ -962,19 +963,19 @@ def test_main_import_all():
gen_test_data(10, 20, 'data.tsv')
main.main('out.tsv data.tsv'.split())
main.main('-nb out.tsv data.tsv'.split())
baseline = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
main.main('--import_all -ow out.tsv data.tsv'.split())
main.main('--import_all -nb -ow out.tsv data.tsv'.split())
passthru = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
assert np.all(baseline == passthru)
main.main('-v 1:3 --import_all -ow out.tsv data.tsv'.split())
main.main('-v 1:3 --import_all -nb -ow out.tsv data.tsv'.split())
dropvars = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
exp = baseline.loc[:, ['1-0.0', '2-0.0', '3-0.0']]
assert np.all(dropvars == exp)
main.main('-v 3:-1:1 --import_all -ow out.tsv data.tsv'.split())
main.main('-v 3:-1:1 --import_all -nb -ow out.tsv data.tsv'.split())
ordered = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
exp = baseline.loc[:, ['3-0.0', '2-0.0', '1-0.0']]
assert np.all(ordered == exp)
......@@ -1246,7 +1247,7 @@ def test_main_child_values():
main.main(shlex.split('-cv 1 "v3 > 400,v2 == 20" "20,50" '
'-cv 2 "v3 < 200" "50" '
'out.tsv data.tsv'))
'-nb out.tsv data.tsv'))
got = pd.read_csv('out.tsv', delimiter='\t', index_col=0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment