def test_run_tableexport_compounds(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'compounds']) self.assertEqual( f.getvalue(), '\n'.join( ['id\tin_model', 'A_\u2206\tTrue', 'B\tTrue', 'C\tTrue', '']))
def test_solver_command_main(self): with self.assertRaises(generic.RequirementsError): main(MockSolverCommand, args=[ '--model', self._model_dir, '--solver', 'name=not-an-actual-solver' ])
def test_run_tableexport_compounds(self): with redirected_stdout() as f: main(args=[ '--model', self._model_dir, 'tableexport', 'compounds']) self.assertEqual(f.getvalue(), '\n'.join([ 'id', 'A_\u2206', 'B', 'C', '' ]))
def test_run_tableexport_limits(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'limits']) self.assertEqual( f.getvalue(), '\n'.join([ 'Reaction ID\tLower Limits\tUpper Limits', 'rxn_2_\u03c0\tNone\t100', '' ]))
def test_run_tableexport_metadata(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'metadata']) self.assertEqual( f.getvalue(), '\n'.join([ 'Model Name: Test model', 'Biomass Reaction: rxn_1', 'Default Flux Limits: 1000', '' ]))
def run_solver_command(self, args, requirements): with redirected_stdout() as f: if self.is_solver_available(**requirements): main(args=args) else: with self.assertRaises(generic.RequirementsError): main(args=args) return f
def test_run_tableexport_medium(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'medium']) self.assertEqual( f.getvalue(), '\n'.join([ 'Compound ID\tReaction ID\tLower Limit\tUpper Limit', 'A_\u2206[e]\tNone\t-1000\t1000', 'C[e]\tNone\t-1000\t1000', '' ]))
def test_run_tableexport_reactions(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'reactions']) self.assertEqual( f.getvalue(), '\n'.join([ 'id\tequation\tgenes', "rxn_1\t|A[e]| => |B[c]|\t['gene_1', 'gene_2']", 'rxn_2\t|B[c]| => |C[e]|\tgene_3 or (gene_4 and gene_5)', '' ]))
def test_run_tableexport_limits(self): with redirected_stdout() as f: main(args=[ '--model', self._model_dir, 'tableexport', 'limits']) self.assertEqual(f.getvalue(), '\n'.join([ 'Reaction ID\tLower Limits\tUpper Limits', 'rxn_2_\u03c0\tNone\t100', '' ]))
def test_run_tableexport_metadata(self): with redirected_stdout() as f: main(args=[ '--model', self._model_dir, 'tableexport', 'metadata']) self.assertEqual(f.getvalue(), '\n'.join([ 'Model Name: Test model', 'Biomass Reaction: rxn_1', 'Default Flux Limits: 1000', '' ]))
def test_run_tableexport_medium(self): with redirected_stdout() as f: main(args=[ '--model', self._model_dir, 'tableexport', 'medium']) self.assertEqual(f.getvalue(), '\n'.join([ 'Compound ID\tReaction ID\tLower Limit\tUpper Limit', 'A_\u2206[e]\tNone\t-1000\t1000', 'C[e]\tNone\t-1000\t1000', '' ]))
def test_run_tableexport_reactions(self): with redirected_stdout() as f: main(args=[ '--model', self._model_dir, 'tableexport', 'reactions']) self.assertEqual(f.getvalue(), '\n'.join([ 'id\tequation\tgenes', "rxn_1\t|A_\u2206[e]| => |B[c]|\t['gene_1', 'gene_2']", 'rxn_2_\u03c0\t|B[c]| => |C[e]|\tgene_3 or (gene_4 and gene_5)', '' ]))
def test_run_tableexport_reactions(self): with redirected_stdout() as f: main(args=['--model', self._model_dir, 'tableexport', 'reactions']) self.assertEqual( f.getvalue(), '\n'.join('\t'.join(row) for row in [['id', 'equation', 'genes', 'in_model'], [ 'rxn_1', '|A_\u2206[e]| => |B[c]|', "['gene_1', 'gene_2']", 'True' ], [ 'rxn_2_\u03c0', '|B[c]| => |C[e]|', 'gene_3 or (gene_4 and gene_5)', 'True' ], ['rxn_3', '|D[c]| => |E[c]|', 'None', 'True'], []]))
def test_run_search_reaction(self): with redirected_stdout(): main(args=[ '--model', self._model_dir, 'search', 'reaction', '--id', 'rxn_1'])
def test_run_search_compound(self): with redirected_stdout(): main(args=[ '--model', self._model_dir, 'search', 'compound', '--id', 'A'])
def test_run_sbmlexport(self): with redirected_stdout(BytesIO()): main(args=['--model', self._model_dir, 'sbmlexport'])
def test_run_formulacheck(self): with redirected_stdout(): main(args=['--model', self._model_dir, 'formulacheck'])
def test_run_search_reaction(self): with redirected_stdout(): main(args=[ '--model', self._model_dir, 'search', 'reaction', '--id', 'rxn_1' ])
def test_run_chargecheck(self): with redirected_stdout(): main(args=['--model', self._model_dir, 'chargecheck'])
def test_solver_command_main(self): with self.assertRaises(generic.RequirementsError): main(MockSolverCommand, args=[ '--model', self._model_dir, '--solver', 'name=not-an-actual-solver'])
def test_command_main(self): main(MockCommand, args=['--model', self._model_dir, '--test-argument']) self.assertTrue(MockCommand.run_called) self.assertTrue(MockCommand.init_parser_called) self.assertTrue(MockCommand.has_native_model)
def test_run_excelexport(self): dest_path = os.path.join(self._model_dir, 'model.xlsx') with redirected_stdout(): main(args=['--model', self._model_dir, 'excelexport', dest_path]) self.assertTrue(os.path.isfile(dest_path))
def test_invoke_version(self): with redirected_stdout(): with self.assertRaises(SystemExit) as context: main(args=['--version']) self.assertEqual(context.exception.code, 0)
def test_command_main(self): main(MockCommand, args=[ '--model', self._model_dir, '--test-argument']) self.assertTrue(MockCommand.run_called) self.assertTrue(MockCommand.init_parser_called) self.assertTrue(MockCommand.has_native_model)
def test_run_search_compound(self): with redirected_stdout(): main(args=[ '--model', self._model_dir, 'search', 'compound', '--id', 'A' ])
def test_metabolic_command_main(self): main(MockMetabolicCommand, args=[ '--model', self._model_dir]) self.assertTrue(MockMetabolicCommand.has_metabolic_model)
def test_metabolic_command_main(self): main(MockMetabolicCommand, args=['--model', self._model_dir]) self.assertTrue(MockMetabolicCommand.has_metabolic_model)