def test_org_find_by_name_inactive(session): # pylint:disable=unused-argument """Assert that an inactive Org can not be retrieved by its name.""" org = factory_org_model(name='My Test Org', session=session) session.add(org) session.commit() org.delete() found_org = OrgModel.find_by_org_name(org.name) assert len(found_org) == 0
def test_org_find_by_name(session): # pylint:disable=unused-argument """Assert that an Org can retrieved by its name.""" org = factory_org_model(name='My Test Org', session=session) session.add(org) session.commit() found_org = OrgModel.find_by_org_name(org.name) assert found_org for org1 in found_org: assert org1.name == org.name
def find_by_org_name(org_name): """Find and return an existing organization with the provided name.""" if org_name is None: return None org_model = OrgModel.find_by_org_name(org_name) if not org_model: return None orgs = {'orgs': []} for org in org_model: orgs['orgs'].append(Org(org).as_dict()) return orgs