示例#1
0
def init():
    context.setup_configuration(CONFIGURATION_FILENAME)
    database.init_db()

    context.log_queue = multiprocessing.Queue()
    context.request_processor = RequestProcessor()
    context.event_handler_manager = EventHandlerManager()
示例#2
0
def init():
    context.setup_configuration(CONFIGURATION_FILENAME)
    database.init_db()

    context.log_queue = multiprocessing.Queue()
    context.request_processor = RequestProcessor()
    context.event_handler_manager = EventHandlerManager()
def setup(mock_log):
    '''
    Runs setup before and clean up after a test which use this fixture
    '''
    # prepare database for test
    database.init_db()
    database.create_database()
    prepare_demodata()
示例#4
0
def init():
    database.init_db()

    current_revision = database.get_current_revision()
    head_revision = database.get_head_revision()
    if head_revision != current_revision:
        print("Database is not up to date! "
              "To upgrade database run pushkin --configuration {cfg} --upgrade-db".format(cfg=CONFIGURATION_FILENAME))
        sys.exit(1)

    context.log_queue = multiprocessing.Queue()
    context.request_processor = RequestProcessor()
    context.event_handler_manager = EventHandlerManager()
    context.message_blacklist = {row.login_id:set(row.blacklist) for row in database.get_all_message_blacklist()}
示例#5
0
def main():
    global CONFIGURATION_FILENAME

    parser = argparse.ArgumentParser(description='Service for sending push notifications')
    parser.add_argument('--configuration', dest='configuration_filename', required=True, help='Configuration file')
    parser.add_argument('--init-db', help='Initialize database', action='store_true')

    args = parser.parse_args()
    absolute_configuration_path = os.path.abspath(args.configuration_filename)

    CONFIGURATION_FILENAME = absolute_configuration_path

    if args.init_db:
        context.setup_configuration(CONFIGURATION_FILENAME)
        database.init_db()
        database.create_database()
    else:
        run()
示例#6
0
def main():
    global CONFIGURATION_FILENAME

    parser = argparse.ArgumentParser(description='Service for sending push notifications')
    parser.add_argument('--configuration', dest='configuration_filename', required=True, help='Configuration file')
    parser.add_argument('--init-db', help='Initialize database', action='store_true')

    args = parser.parse_args()
    absolute_configuration_path = os.path.abspath(args.configuration_filename)

    CONFIGURATION_FILENAME = absolute_configuration_path

    if args.init_db:
        context.setup_configuration(CONFIGURATION_FILENAME)
        database.init_db()
        database.create_database()
    else:
        run()
示例#7
0
def init():
    database.init_db()

    current_revision = database.get_current_revision()
    head_revision = database.get_head_revision()
    if head_revision != current_revision:
        print(
            "Database is not up to date! "
            "To upgrade database run pushkin --configuration {cfg} --upgrade-db"
            .format(cfg=CONFIGURATION_FILENAME))
        sys.exit(1)

    context.log_queue = multiprocessing.Queue()
    context.request_processor = RequestProcessor()
    context.event_handler_manager = EventHandlerManager()
    context.message_blacklist = {
        row.login_id: set(row.blacklist)
        for row in database.get_all_message_blacklist()
    }
示例#8
0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
import pytest
from pushkin.request.requests import EventRequestSingle
from pushkin.protobuf import EventMessage_pb2
from pushkin.request.requests import EventRequestBatch
from pushkin.request.event_handlers import EventHandlerManager
from pushkin import context

from pushkin import config
from pushkin.database import database
from pushkin import test_config_ini_path

context.setup_configuration(test_config_ini_path)
database.init_db()


@pytest.fixture
def mock_log(mocker):
    mocker.patch("pushkin.context.main_logger")


@pytest.fixture
def setup(mock_log):
    '''
    Runs setup before and clean up after a test which use this fixture
    '''
    # prepare database for test
    database.create_database()
    prepare_demodata()
示例#9
0
def setup_database():
    database.init_db()
    database.create_database()
示例#10
0
def setup_database():
    database.init_db()
    database.create_database()
示例#11
0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
import pytest
from pushkin.request.requests import EventRequestSingle
from pushkin.protobuf import EventMessage_pb2
from pushkin.request.requests import EventRequestBatch
from pushkin.request.event_handlers import EventHandlerManager
from pushkin import context

from pushkin import config
from pushkin.database import database
from pushkin import test_config_ini_path

context.setup_configuration(test_config_ini_path)
database.init_db()

@pytest.fixture
def mock_log(mocker):
    mocker.patch("pushkin.context.main_logger")


@pytest.fixture
def setup(mock_log):
    '''
    Runs setup before and clean up after a test which use this fixture
    '''
    # prepare database for test
    database.create_database()
    prepare_demodata()