# modules in this package import cas_auth import genshi_render import drocnotice import stats import perf_reports from admin_lib import medcenter from admin_lib import heron_policy from admin_lib import redcap_connect from admin_lib import rtconfig from admin_lib.rtconfig import Options, TestTimeOptions from admin_lib import disclaimer from admin_lib.ocap_file import WebReadable, Token, Path import traincheck KAppSettings = injector.Key('AppSettings') KI2B2Address = injector.Key('I2B2Address') KErrorOptions = injector.Key('ErrorOptions') log = logging.getLogger(__name__) def test_home_page_redirects_to_cas(): '''A plain request for the homepage redirects us to the CAS login page: >>> t, r1 = test_home_page_redirects_to_cas() >>> dict(r1.headers)['Location'] 'https://example/cas/login?service=http%3A%2F%2Fheron-service%2F' ''' from paste.fixture import TestApp
import injector from injector import inject, provides, singleton import rtconfig import ldaplib import sealing from notary import makeNotary from ocap_file import WebReadable, Path log = logging.getLogger(__name__) TRAINING_SECTION = 'training' # Injector keys are not shareable, so... KTrainingFunction = (type(lambda: 1), TRAINING_SECTION) KExecutives = injector.Key('Executives') KTestingFaculty = injector.Key('TestingFaculty') KStudyTeamLookup = injector.Key('StudyTeamLookup') PERM_BROWSER = __name__ + '.browse' PERM_BADGE = __name__ + '.badge' @singleton class Browser(object): ''''Search the directory and study teams without conferring authority. >>> (m, ) = Mock.make([Browser]) >>> hits = m.search(10, 'john.smith', '', '') >>> hits [John Smith <*****@*****.**>]
''' import logging import injector from injector import inject, provides, singleton from sqlalchemy import text, orm, Table, MetaData import jndi_util import rtconfig import ocap_file log = logging.getLogger(__name__) CONFIG_SECTION_MD = 'i2b2md' Ki2b2meta_schema = injector.Key('i2b2meta_schema') class I2B2Metadata(ocap_file.Token): @inject(metadatasm=(orm.session.Session, CONFIG_SECTION_MD), i2b2meta_schema=Ki2b2meta_schema) def __init__(self, metadatasm, i2b2meta_schema): ''' :param metadatasm: a function that returns an sqlalchemy session ''' self._mdsm = metadatasm self.i2b2meta_schema = i2b2meta_schema def project_terms(self, i2b2_pid, rc_pids, rct_table='REDCAP_TERMS'): '''Create heron_terms view in the chosen i2b2 project. '''
import injector from injector import inject, provides, singleton from sqlalchemy import Column, ForeignKey, and_ from sqlalchemy import func, orm from sqlalchemy.types import String, DateTime, Enum from sqlalchemy.ext.declarative import declarative_base import rtconfig import jndi_util import ocap_file import i2b2metadata from sqlite_mem import _test_engine CONFIG_SECTION = 'i2b2pm' KUUIDGen = injector.Key('UUIDGen') KIdentifiedData = injector.Key('IdentifiedData') DEFAULT_PID = 'BlueHeron' Base = declarative_base() log = logging.getLogger(__name__) class I2B2PM(ocap_file.Token): @inject(datasrc=(orm.session.Session, CONFIG_SECTION), i2b2md=i2b2metadata.I2B2Metadata, identified_data=KIdentifiedData, uuidgen=KUUIDGen) def __init__(self, datasrc, i2b2md, identified_data, uuidgen): '''
from injector import inject, provides from pyramid.response import Response from pyramid_mailer.mailer import Mailer, DummyMailer from pyramid_mailer.message import Message import sqlalchemy from sqlalchemy.sql import func import genshi_render from admin_lib import heron_policy from admin_lib.noticelog import DecisionRecords from admin_lib import noticelog from admin_lib import redcapdb from admin_lib import rtconfig from admin_lib.ocap_file import Token KMailSettings = injector.Key('MailSettings') log = logging.getLogger(__name__) class DROCNotice(Token): # We send notice only on final decisions, not defer. FINAL_DECISIONS = (DecisionRecords.YES, DecisionRecords.NO) '''Route to HERON home page. ''' home = 'heron_home' # oops... should be passed in from heron_srv @inject(dr=DecisionRecords, smaker=(sqlalchemy.orm.session.Session, redcapdb.CONFIG_SECTION), mailer=Mailer) def __init__(self, dr, smaker, mailer): self._dr = dr
import injector from injector import inject, provides, singleton from sqlalchemy import Column, ForeignKey, and_ from sqlalchemy import func, orm from sqlalchemy.types import String, DateTime, Enum from sqlalchemy.ext.declarative import declarative_base import rtconfig import jndi_util import ocap_file import i2b2metadata from sqlite_mem import _test_engine CONFIG_SECTION = 'i2b2pm' KUUIDGen = injector.Key('UUIDGen') KIdentifiedData = injector.Key('IdentifiedData') Ki2b2crc_schema = injector.Key('i2b2crc_schema') Ki2b2pm_schema = injector.Key('i2b2pm_schema') DEFAULT_PID = 'BlueHeron' Base = declarative_base() log = logging.getLogger(__name__) class I2B2PM(ocap_file.Token): @inject(datasrc=(orm.session.Session, CONFIG_SECTION), i2b2md=i2b2metadata.I2B2Metadata, identified_data=KIdentifiedData, uuidgen=KUUIDGen)
import pyramid from pyramid import security from pyramid.httpexceptions import HTTPForbidden, HTTPFound, HTTPSeeOther from pyramid.authentication import AuthTktAuthenticationPolicy from pyramid.session import UnencryptedCookieSessionFactoryConfig from admin_lib.rtconfig import (Options, TestTimeOptions, IniModule) from admin_lib.rtconfig import MockMixin from admin_lib.ocap_file import edef, Token, Path from admin_lib.ocap_file import WebReadable log = logging.getLogger(__name__) CONFIG_SECTION = 'cas' KServiceUrl = injector.Key('ServiceUrl') class Issuer(Token): '''Issuer of capabilities based on CAS login credentials. See MockIssuer for an example. ''' permissions = () def __repr__(self): return self.__class__.__name__ + '()' def authenticated(self, uid, req): '''Mark a request's context as authenticated.
import pkg_resources as pkg # from this package from ddict import DataDict from notary import makeNotary from ocap_file import WebReadable, WebPostable, Token, Path from redcapdb import add_mock_eav import medcenter import redcap_api import rtconfig import redcapdb DISCLAIMERS_SECTION = 'disclaimers' ACKNOWLEGEMENTS_SECTION = 'disclaimer_acknowledgements' KNotary = injector.Key('Notary') KBadgeInspector = injector.Key('BadgeInspector') log = logging.getLogger(__name__) class Disclaimer(redcapdb.REDCapRecord): fields = ('disclaimer_id', 'url', 'current') def content(self, rdcap): r''' >>> d = Disclaimer() >>> d.url = 'http://example/' >>> d.content(_MockTracBlog()) ... # doctest: +ELLIPSIS ('<div id="blog-main">\n<h1 class="blog-title">...', 'headline')
from sqlalchemy.types import Integer, VARCHAR, TIMESTAMP from sqlalchemy.schema import ForeignKey from sqlalchemy import orm from sqlalchemy.sql import select, func, and_ import pkg_resources as pkg import rtconfig import redcapdb from redcap_connect import _test_settings as rc_test_settings from ddict import DataDict import medcenter from ocap_file import Token, Path log = logging.getLogger(__name__) OVERSIGHT_CONFIG_SECTION = 'oversight_survey' KProjectId = injector.Key('ProjectId') KNoticeLogSchema = injector.Key('NoticeLogSchema') notice_log = Table('notice_log', redcapdb.Base.metadata, Column('id', Integer, primary_key=True), Column('record', VARCHAR(100), ForeignKey('redcap_data.record')), Column('timestamp', TIMESTAMP()), mysql_engine='InnoDB', mysql_collate='utf8_unicode_ci') class DecisionRecords(Token): ''' .. note:: At test time, let's check consistency with the data dictionary.