This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
from urllib.parse import urlparse | |
import random | |
from sqlalchemy import ( | |
Column, | |
Index, | |
Integer, | |
String, DateTime, ForeignKey) | |
from pyramid_web20.models import Base, utc, now, DBSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""websauna.referral library initialization code.""" | |
import logging | |
from sqlalchemy.ext.declarative import instrument_declarative | |
from pyramid_web20.system.model import Base | |
from . import models | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wrap_wsgi_app(self, app): | |
"""Perform any necessary WSGI application wrapping. | |
Wrap WSGI application to another WSGI application e.g. for the monitoring support. By default support New Relic. | |
""" | |
if "NEW_RELIC_CONFIG_FILE" in os.environ: | |
# Wrap for New Relic | |
# libgcc_s.so.1 must be installed for pthread_cancel to work | |
import newrelic.agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""CRUD based on SQLAlchemy and Deform.""" | |
from abc import abstractmethod, abstractproperty | |
from websauna.system.core import traverse | |
from . import mapper | |
class CRUD(traverse.Resource): | |
"""Define create-read-update-delete interface for an model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Compatibility layer between different Python versions.""" | |
import sys | |
if sys.version_info >= (3, 5): | |
import typing | |
else: | |
from backports import typing | |
# Then from compat import typing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from websauna.system.model import DBSession | |
EMAIL = "example@example.com" | |
PASSWORD = "ToholamppiMadCowz585" | |
def get_user(): | |
from websauna.system.user.models import User | |
return DBSession.query(User).get(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pytest | |
def do_facebook_login(browser): | |
fb_user = os.environ.get("FACEBOOK_USER") | |
assert fb_user, "Please configure your Facebook secrets as environment variables to run the tests" | |
fb_password = os.environ["FACEBOOK_PASSWORD"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ServerThread(threading.Thread): | |
""" Run WSGI server on a background thread. | |
Pass in WSGI app object and serve pages from it for Selenium browser. | |
""" | |
def __init__(self, app, hostbase=HOST_BASE): | |
threading.Thread.__init__(self) | |
self.app = app | |
self.srv = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ServerThread(threading.Thread): | |
""" Run WSGI server on a background thread. | |
Pass in WSGI app object and serve pages from it for Selenium browser. | |
""" | |
def __init__(self, app, hostbase=HOST_BASE): | |
threading.Thread.__init__(self) | |
self.app = app | |
self.srv = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pyramid.testing | |
import pytest | |
import transaction | |
from sqlalchemy.orm.session import Session | |
from pyramid.paster import ( | |
get_appsettings, | |
setup_logging, |