def test_sbol_role(self, nm_url, cell_val, raising_err, roles, expected,
                       sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)
        if len(roles) > 0:
            for role in roles:
                sbol_component.roles = sbol_component.roles + [
                    f'http://purl.obolibrary.org/obo/SO_{role}'
                ]

        if raising_err:
            with pytest.raises(expected):
                x.sbol_role()

        else:
            expected = [
                f'http://purl.obolibrary.org/obo/SO_{role}'
                for role in expected
            ]
            x.sbol_role()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            assert set(comp.roles) == set(expected)
    def test_sbol_displayId(self, nm_url, cell_val, raising_err, expected1,
                            expected2, sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)
        if raising_err:
            with pytest.raises(expected1):
                x.sbol_displayId()

        else:
            x.sbol_displayId()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            assert comp.name == expected1 and comp.displayId == expected2
    def test_dcterms_description(self, nm_url, cell_val, raising_err, expected,
                                 sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)
        if raising_err:
            with pytest.raises(expected):
                x.dcterms_description()

        else:
            x.dcterms_description()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                f'http://examples.org/{sbol_component.name}/1']
            assert comp.description == expected
    def test_sbh_alteredSequence(self, nm_url, cell_val, raising_err, expected,
                                 sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)

        if raising_err:
            with pytest.raises(expected):
                x.sbh_alteredSequence()

        else:
            x.sbh_alteredSequence()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            assert comp.wasGeneratedBy[0] == expected
    def test_sbh_sourceOrganism(self, nm_url, cell_val, raising_err, expected,
                                sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)

        if raising_err:
            with pytest.raises(expected):
                x.sbh_sourceOrganism()

        else:
            x.sbh_sourceOrganism()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            assert comp.sourceOrganism == expected
    def test_switch(self, sbol_term, nm_url, cell_val, raising_err, expected,
                    sbol_component, sbol_doc, monkeypatch):
        def fake_NA(self):
            return "fake_NA"

        def fake_add_new(self):
            return "fake_add_new"

        monkeypatch.setattr(cf.sbol_methods, 'Not_applicable', fake_NA)
        monkeypatch.setattr(cf.sbol_methods, 'add_new', fake_add_new)

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)
        if raising_err:
            with pytest.raises(expected):
                x.switch(sbol_term)
        else:
            assert x.switch(sbol_term) == expected
    def test_add_new(self, nm_url, sbol_term, cell_val, raising_err, expected,
                     sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)
        x.sbol_term = sbol_term

        if raising_err:
            with pytest.raises(expected):
                x.add_new()

        else:
            x.add_new()
            sbol_doc.addComponentDefinition(sbol_component)
            sbol_term_sfx = sbol_term.split("_", 1)[1]

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            comp_attr = getattr(comp, sbol_term_sfx)
            assert comp_attr == expected
    def test_sbol_sequence(self, nm_url, cell_val, raising_err, expected,
                           sbol_component, sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)

        if raising_err:
            with pytest.raises(expected):
                x.sbol_sequence()

        else:
            x.sbol_sequence()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                f'http://examples.org/{sbol_component.name}/1']
            seq = sbol_doc.sequences[
                f'http://examples.org/{sbol_component.name}_sequence/1']

            assert seq.elements == expected and str(
                comp.sequence
            ) == f'http://examples.org/{sbol_component.name}_sequence/1'
    def test_sbh_dataSource(self, nm_url, cell_val, raising_err,
                            pubmedExpected, expected, sbol_component,
                            sbol_doc):

        x = cf.sbol_methods(nm_url, sbol_component, sbol_doc, cell_val)

        if raising_err:
            with pytest.raises(expected):
                x.sbh_dataSource()

        else:
            x.sbh_dataSource()
            sbol_doc.addComponentDefinition(sbol_component)

            comp = sbol_doc.componentDefinitions[
                'http://examples.org/test_comp_name/1']
            if pubmedExpected:
                identi = os.path.split(expected)[1]
                assert comp.wasDerivedFrom[
                    0] == expected and comp.OBI_0001617 == identi
            else:
                assert comp.wasDerivedFrom[0] == expected