# Path: doorman/application.py
# def create_app(config=ProdConfig):
#     app = Flask(__name__)
#     app.config.from_object(config)
#     app.config.from_envvar('DOORMAN_SETTINGS', silent=True)
# 
#     register_blueprints(app)
#     register_errorhandlers(app)
#     register_loggers(app)
#     register_extensions(app)
#     register_auth_method(app)
#     register_filters(app)
# 
#     return app
# 
# Path: doorman/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, record_id):
# def reference_col(tablename, nullable=False, pk_name='id', **kwargs):
# 
# Path: doorman/models.py
# class Rule(SurrogatePK, Model):
# 
#     name = Column(db.String, nullable=False)
#     alerters = Column(ARRAY(db.String), nullable=False)
#     description = Column(db.String, nullable=True)
#     conditions = Column(JSONB)
#     updated_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
# 
#     def __init__(self, name, alerters, description=None, conditions=None, updated_at=None):
#         self.name = name
#         self.description = description
#         self.alerters = alerters
#         self.conditions = conditions
#         self.updated_at = updated_at
# 
#     @property
#     def template(self):
#         return string.Template("{name}\r\n\r\n{description}".format(
#             name=self.name, description=self.description or '')
#         )
# 
# Path: doorman/settings.py
# class TestConfig(Config):
#     """
#     This class specifies a configuration that is used for our tests.
#     """
#     TESTING = True
#     DEBUG = True
# 
#     SQLALCHEMY_DATABASE_URI = 'postgresql://localhost:5432/doorman_test'
# 
#     WTF_CSRF_ENABLED = False
# 
#     DOORMAN_ENROLL_SECRET = [
#         'secret',
#     ]
#     DOORMAN_EXPECTS_UNIQUE_HOST_ID = False
# 
#     DOORMAN_AUTH_METHOD = None
# 
#     DOORMAN_COLUMN_RENDER = {
#         'computer_name': '<a href="https://{{ value | urlencode }}/">{{ value }}</a>'
#     }
# 
# Path: tests/factories.py
# class NodeFactory(BaseFactory):
# 
#     class Meta:
#         model = Node
# 
# class RuleFactory(BaseFactory):
# 
#     class Meta:
#         model = Rule


import pytest
    import os
from webtest import TestApp
from doorman.application import create_app
from doorman.database import db as _db
from doorman.models import Rule
from doorman.settings import TestConfig
from .factories import NodeFactory, RuleFactory
# -*- coding: utf-8 -*-
"""Defines fixtures available to all tests."""





@pytest.yield_fixture(scope='function')
def app():
    """An application for the tests."""
    _app = create_app(config=TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    try:
        yield _app
    finally:
        ctx.pop()


@pytest.yield_fixture(scope='function')
def api():
    """An api instance for the tests, no manager"""
    # the mere presence of the env var should prevent the manage
    # blueprint from being registered
    os.environ['DOORMAN_NO_MANAGER'] = '1'


# Path: doorman/application.py
# def create_app(config=ProdConfig):
#     app = Flask(__name__)
#     app.config.from_object(config)
#     app.config.from_envvar('DOORMAN_SETTINGS', silent=True)
# 
#     register_blueprints(app)
#     register_errorhandlers(app)
#     register_loggers(app)
#     register_extensions(app)
#     register_auth_method(app)
#     register_filters(app)
# 
#     return app
# 
# Path: doorman/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, record_id):
# def reference_col(tablename, nullable=False, pk_name='id', **kwargs):
# 
# Path: doorman/models.py
# class Rule(SurrogatePK, Model):
# 
#     name = Column(db.String, nullable=False)
#     alerters = Column(ARRAY(db.String), nullable=False)
#     description = Column(db.String, nullable=True)
#     conditions = Column(JSONB)
#     updated_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)
# 
#     def __init__(self, name, alerters, description=None, conditions=None, updated_at=None):
#         self.name = name
#         self.description = description
#         self.alerters = alerters
#         self.conditions = conditions
#         self.updated_at = updated_at
# 
#     @property
#     def template(self):
#         return string.Template("{name}\r\n\r\n{description}".format(
#             name=self.name, description=self.description or '')
#         )
# 
# Path: doorman/settings.py
# class TestConfig(Config):
#     """
#     This class specifies a configuration that is used for our tests.
#     """
#     TESTING = True
#     DEBUG = True
# 
#     SQLALCHEMY_DATABASE_URI = 'postgresql://localhost:5432/doorman_test'
# 
#     WTF_CSRF_ENABLED = False
# 
#     DOORMAN_ENROLL_SECRET = [
#         'secret',
#     ]
#     DOORMAN_EXPECTS_UNIQUE_HOST_ID = False
# 
#     DOORMAN_AUTH_METHOD = None
# 
#     DOORMAN_COLUMN_RENDER = {
#         'computer_name': '<a href="https://{{ value | urlencode }}/">{{ value }}</a>'
#     }
# 
# Path: tests/factories.py
# class NodeFactory(BaseFactory):
# 
#     class Meta:
#         model = Node
# 
# class RuleFactory(BaseFactory):
# 
#     class Meta:
#         model = Rule


# Path: tests/conftest.py
import pytest
    import os
from webtest import TestApp
from doorman.application import create_app
from doorman.database import db as _db
from doorman.models import Rule
from doorman.settings import TestConfig
from .factories import NodeFactory, RuleFactory

# -*- coding: utf-8 -*-
"""Defines fixtures available to all tests."""





@pytest.yield_fixture(scope='function')
def app():
    """An application for the tests."""
    _app = create_app(config=TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    try:
        yield _app
    finally:
        ctx.pop()


@pytest.yield_fixture(scope='function')
def api():
    """An api instance for the tests, no manager"""
    # the mere presence of the env var should prevent the manage
    # blueprint from being registered
    os.environ['DOORMAN_NO_MANAGER'] = '1'


    _app = create_app(config=TestConfig)