Skip to content

Commit d3571d6

Browse files
committed
some tests
1 parent b4ff44b commit d3571d6

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

mmeds/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
# Check where this code is being run
18+
print(getfqdn().split('.'))
1819
TESTING = not ('chimera' in getfqdn().split('.'))
1920

2021
# If not running on web03, can't connect to databases
@@ -437,10 +438,10 @@
437438
TEST_CODE_LEFSE = 'lefsetable'
438439
TEST_FORMAT_HUMANN_MAPPING = str(TEST_PATH / 'test_qiime_mapping_file_format_to_humann.tsv')
439440
TEST_FORMAT_HUMANN_TABLE = str(TEST_PATH / 'test_BRITE_pathways_stratified_format_to_humann.tsv')
440-
TEST_FORMAT_HUMANN_RESULT = str(TEST_PATH / 'test_taxa_table_L7_format_to_lefse.tsv')
441+
TEST_FORMAT_HUMANN_RESULT = str(TEST_PATH / 'test_formatted_humann_table.tsv')
441442
TEST_FORMAT_LEFSE_MAPPING = str(TEST_PATH / 'test_qiime_mapping_file_format_to_lefse.tsv')
442443
TEST_FORMAT_LEFSE_TABLE = str(TEST_PATH / 'test_taxa_table_L7_format_to_lefse.tsv')
443-
TEST_FORMAT_LEFSE_RESULT = str(TEST_PATH / 'test_taxa_table_L7_format_to_lefse.tsv')
444+
TEST_FORMAT_LEFSE_RESULT = str(TEST_PATH / 'test_formatted_lefse_table.tsv')
444445
TEST_MIXS = str(TEST_PATH / 'test_MIxS.tsv')
445446
TEST_MIXS_MMEDS = str(TEST_PATH / 'MIxS_metadata.tsv')
446447
TEST_OTU = str(TEST_PATH / 'test_otu_table.txt')
@@ -708,7 +709,7 @@
708709
try:
709710
db = pms.connect(host='localhost',
710711
user='root',
711-
password='root',
712+
password="",
712713
db=SQL_DATABASE,
713714
max_allowed_packet=2048000000,
714715
local_infile=True)

mmeds/tests/unit/test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def setup_tests(tests):
4646
'Test_Single_Short',
4747
testing,
4848
fig.TEST_CODE_SHORT))
49+
test_setup.append((fig.TEST_SUBJECT_SHORT,
50+
'human',
51+
fig.TEST_SPECIMEN_PAIRED,
52+
fig.TEST_USER,
53+
'Test_Paired',
54+
testing,
55+
fig.TEST_CODE_PAIRED))
4956
if 'tools' in tests or 'analysis' in tests:
50-
test_setup.append((fig.TEST_SUBJECT_SHORT,
51-
'human',
52-
fig.TEST_SPECIMEN_PAIRED,
53-
fig.TEST_USER,
54-
'Test_Paired',
55-
testing,
56-
fig.TEST_CODE_PAIRED))
5757
test_setup.append((fig.TEST_SUBJECT_SHORT,
5858
'human',
5959
fig.TEST_SPECIMEN_DEMUXED,

mmeds/tests/unit/test_util.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ def test_q_metadata_concat_and_split(self):
293293
entries = {'Test_Single_Short': ['L6S93', 'L6S95'],
294294
'Test_Paired': ['L6S98', 'L6S99']}
295295
paths = {'Test_Single_Short':
296-
'/home/runner/mmeds_server_data/studies/testuser_Test_Single_Short_0/full_metadata.tsv',
296+
Path(fig.DATABASE_DIR) / "studies" / "testuser_Test_Single_Short_0" / "full_metadata.tsv",
297297
'Test_Paired':
298-
'/home/runner/mmeds_server_data/studies/testuser_Test_Paired_0/full_metadata.tsv'}
298+
Path(fig.DATABASE_DIR) / "studies" / "testuser_Test_Paired_0" / "full_metadata.tsv"}
299299

300300
df = util.concatenate_metadata_subsets(entries, paths)
301301
subj_df, spec_df = util.split_metadata(df, 'human', new_study_name="New_Test_Study")
@@ -313,7 +313,6 @@ def test_r_format_to_lefse(self):
313313
# Assert created file is equal to test example
314314
self.assertTrue(filecmp.cmp(test_true_result, test_out_result, shallow=False))
315315

316-
317316
def test_s_format_to_humann(self):
318317
""" Test converting to format readable for humann_barplot functions """
319318
tmpdir = Path(gettempdir())
@@ -322,7 +321,12 @@ def test_s_format_to_humann(self):
322321
test_true_result = fig.TEST_FORMAT_HUMANN_RESULT
323322
test_out_result = tmpdir / "test_humann_format_out.tsv"
324323

325-
util.format_table_to_humann(test_table, test_map, ["Stage", "MASLDstatus"], test_out_result, True, True)
324+
util.format_table_to_humann(test_table, test_map, ["MASLDstatus", "Stage"], test_out_result, True, True)
325+
326+
with open(test_out_result, "r") as f1, open(test_true_result, "r") as f2:
327+
for r1, r2 in zip(f1, f2):
328+
if r1 != r2:
329+
print(f"{r1}\nIS NOT EQUAL TO\n{r2}")
326330

327331
# Assert created file is equal to test example
328332
self.assertTrue(filecmp.cmp(test_true_result, test_out_result, shallow=False))

0 commit comments

Comments
 (0)