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 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('--upgrade-db', help='Upgrade database', action='store_true') args = parser.parse_args() absolute_configuration_path = os.path.abspath(args.configuration_filename) CONFIGURATION_FILENAME = absolute_configuration_path context.setup_configuration(CONFIGURATION_FILENAME) if args.upgrade_db: database.upgrade_database() else: run()
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()
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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()
The MIT License (MIT) Copyright (c) 2016 Nordeus LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.database import database import datetime from pushkin import context from pushkin import test_config_ini_path context.setup_configuration(test_config_ini_path) @pytest.fixture def setup_database(): database.init_db() database.create_database() def test_devices(setup_database): database.process_user_login(login_id=12345, language_id=7, platform_id=1, device_id='qwe', device_token='123', application_version=1007) assert list(database.get_device_tokens(login_id=12345)) == [(1, '123')] database.process_user_login(login_id=12345, language_id=7, platform_id=1, device_id=None, device_token='123', application_version=1007) database.process_user_login(login_id=12345, language_id=7, platform_id=1, device_id='qwe', device_token=None,