# Path: amivapi/settings.py
# EMAIL_REGEX = '^.+@.+$'
# 
# REDIRECT_URI_REGEX = '^((http://)?localhost[^#]*|https://[^#]+)$'
# 
# Path: amivapi/utils.py
# @contextmanager
# def admin_permissions():
#     """Switch to a context with admin rights and restore state afterwards.
# 
#     Use as context:
#     >> with admin_rights():
#     >>     do_something()
#     """
#     old_admin = g.get('resource_admin')
#     g.resource_admin = True
# 
#     yield
# 
#     if old_admin is not None:  # None means it wasn't set before..
#         g.resource_admin = old_admin


from datetime import date, datetime, timedelta
from os.path import dirname, join
from contextlib import contextmanager
from bson import ObjectId
from eve.methods.post import post_internal
from werkzeug.datastructures import FileStorage
from amivapi.settings import EMAIL_REGEX, REDIRECT_URI_REGEX
from amivapi.utils import admin_permissions
import random
import string

        if 'password' not in obj:
            username = obj['username']

            # find the user in the fixture and insert his password
            for user in fixture['users']:
                if username in (user.get('nethz'),
                                user.get('email'),
                                str(user.get('_id'))):
                    obj['password'] = user['password']

            if 'password' not in obj:
                raise BadFixtureException(
                    "Could not determine password for user %s in fixture with "
                    "unspecified password for session %s"
                    % (obj['username'], obj))

    def preprocess_apikeys(self, schema, obj, fixture):
        if 'permissions' not in obj:
            # Create some random permission
            resource = random.choice(list(self.app.config['DOMAIN'].keys()))
            permission = (
                random.choice(schema['permissions']['valuesrules']['allowed']))

            obj['permissions'] = {resource: permission}

    def preprocess_events(self, schema, obj, fixture):
        """Event validators are pretty complex, so do all thing with custom
        validators by hand"""
        # Add either german or englisch texts

# Path: amivapi/settings.py
# EMAIL_REGEX = '^.+@.+$'
# 
# REDIRECT_URI_REGEX = '^((http://)?localhost[^#]*|https://[^#]+)$'
# 
# Path: amivapi/utils.py
# @contextmanager
# def admin_permissions():
#     """Switch to a context with admin rights and restore state afterwards.
# 
#     Use as context:
#     >> with admin_rights():
#     >>     do_something()
#     """
#     old_admin = g.get('resource_admin')
#     g.resource_admin = True
# 
#     yield
# 
#     if old_admin is not None:  # None means it wasn't set before..
#         g.resource_admin = old_admin


# Path: amivapi/tests/fixtures.py
from datetime import date, datetime, timedelta
from os.path import dirname, join
from contextlib import contextmanager
from bson import ObjectId
from eve.methods.post import post_internal
from werkzeug.datastructures import FileStorage
from amivapi.settings import EMAIL_REGEX, REDIRECT_URI_REGEX
from amivapi.utils import admin_permissions
import random
import string


        if 'password' not in obj:
            username = obj['username']

            # find the user in the fixture and insert his password
            for user in fixture['users']:
                if username in (user.get('nethz'),
                                user.get('email'),
                                str(user.get('_id'))):
                    obj['password'] = user['password']

            if 'password' not in obj:
                raise BadFixtureException(
                    "Could not determine password for user %s in fixture with "
                    "unspecified password for session %s"
                    % (obj['username'], obj))

    def preprocess_apikeys(self, schema, obj, fixture):
        if 'permissions' not in obj:
            # Create some random permission
            resource = random.choice(list(self.app.config['DOMAIN'].keys()))
            permission = (
                random.choice(schema['permissions']['valuesrules']['allowed']))

            obj['permissions'] = {resource: permission}

    def preprocess_events(self, schema, obj, fixture):
        """Event validators are pretty complex, so do all thing with custom
        validators by hand"""
        # Add either german or englisch texts

        if random.choice([True, False]):