2828 }
2929}
3030
31- #
3231plasmid_length = {
3332 "ACC1" : "10" ,
3433 "ACC2" : "10"
@@ -43,16 +42,13 @@ def fetch_file(tmpdir, request):
4342 # creates a temporary file with the json_dict
4443 json_dict = tmpdir .join ("test_json_dict.json" )
4544 json_dict .write ('{"ACC1": 2000}' )
46- # executes the function to be tested
47- mapping2json .main (str (depth_file ), str (json_dict ), "0" , "test" )
48- result_dict = json .load (open ("{}_mapping.json" .format (str (depth_file ))))
4945
5046 # finalizer statement that removes .report.json
5147 def remove_test_files ():
5248 os .remove (".report.json" )
5349 request .addfinalizer (remove_test_files )
5450
55- return result_dict , str (depth_file )
51+ return json_dict , str (depth_file )
5652
5753
5854def test_depth_file_reader (tmpdir ):
@@ -62,7 +58,7 @@ def test_depth_file_reader(tmpdir):
6258
6359 # create a temporary file to make a dict from
6460 file_handle = tmpdir .join ("test_depth_file.txt" )
65- file .write ("seq1\t 1\t 30" )
61+ file_handle .write ("seq1\t 1\t 30" )
6662
6763 # execute the function to get the dict
6864 result_dict = mapping2json .depth_file_reader (open (str (file )))
@@ -92,22 +88,30 @@ def test_generate_file(fetch_file):
9288 """
9389 This function tests if the output json file is generated
9490 """
95- _ , depth_file = fetch_file
91+ json_dict , depth_file = fetch_file
92+ # executes the function to be tested
93+ mapping2json .main (str (depth_file ), str (json_dict ), "0" , "test" )
9694 assert os .path .isfile ("{}_mapping.json" .format (depth_file ))
9795
9896
9997def test_generate_report (fetch_file ):
10098 """
10199 This tests if the report.json file is generated
102100 """
101+ json_dict , depth_file = fetch_file
102+ # executes the function to be tested
103+ mapping2json .main (str (depth_file ), str (json_dict ), "0" , "test" )
103104 assert os .path .isfile (".report.json" )
104105
105106
106107def test_generated_dict (fetch_file ):
107108 """
108109 This function checks if the file contains a dict
109110 """
110- result_dict , _ = fetch_file
111+ json_dict , depth_file = fetch_file
112+ # executes the function to be tested
113+ mapping2json .main (str (depth_file ), str (json_dict ), "0" , "test" )
114+ result_dict = json .load (open ("{}_mapping.json" .format (str (depth_file ))))
111115 assert isinstance (result_dict , dict )
112116
113117
@@ -116,5 +120,8 @@ def test_generated_dict_contents(fetch_file):
116120 This function tests if the dictionary in the file has the required fields
117121 """
118122 expected_dict = {"ACC1" : 0.0 }
119- result_dict , _ = fetch_file
123+ json_dict , depth_file = fetch_file
124+ # executes the function to be tested
125+ mapping2json .main (str (depth_file ), str (json_dict ), "0" , "test" )
126+ result_dict = json .load (open ("{}_mapping.json" .format (str (depth_file ))))
120127 assert result_dict == expected_dict
0 commit comments