def test_cmdline_fails(): """Exercise the command line interface""" # No arguments with pytest.raises(SystemExit): Main([]) # Only the association file argument with pytest.raises(SystemExit): Main(['-o', 'test_asn.json'])
def test_cmdline_change_rules(tmpdir): """Command line change the rule""" rule = 'Association' path = tmpdir.join('test_asn.json') inlist = ['a', 'b', 'c'] args = [ '-o', path.strpath, '-r', rule, ] args = args + inlist Main(args) with open(path.strpath, 'r') as fp: asn = load_asn(fp, registry=AssociationRegistry(include_bases=True)) assert inlist == asn['members']
def test_cmdline_success(format, tmpdir): """Create Level3 associations in different formats""" path = tmpdir.join('test_asn.json') product_name = 'test_product' inlist = ['a', 'b', 'c'] args = [ '-o', path.strpath, '--product-name', product_name, '--format', format ] args = args + inlist Main(args) with open(path.strpath, 'r') as fp: asn = load_asn(fp, format=format) assert len(asn['products']) == 1 assert asn['products'][0]['name'] == product_name members = asn['products'][0]['members'] expnames = [ member['expname'] for member in members ] assert inlist == expnames
def test_level2_from_cmdline(tmpdir): """Create a level2 assocaition from the command line""" rule = 'DMSLevel2bBase' path = tmpdir.join('test_asn.json') inlist = ['a', 'b', 'c'] args = [ '-o', path.strpath, '-r', rule, ] args = args + inlist Main(args) with open(path.strpath, 'r') as fp: asn = load_asn(fp, registry=AssociationRegistry(include_bases=True)) assert asn['asn_rule'] == 'DMSLevel2bBase' assert asn['asn_type'] == 'None' products = asn['products'] assert len(products) == len(inlist) for product in products: assert product['name'] in inlist members = product['members'] assert len(members) == 1 member = members[0] assert member['expname'] == product['name'] assert member['exptype'] == 'science'