Example #1
0
def before_feature(context, feature):
    config = getattr(setup_before_all, 'config', None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, 'config', None)
        app_factory = getattr(setup_before_scenario, 'app_factory', None)
    config = config or {}
    app_factory = app_factory or get_app

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    os.environ['BEHAVE_TESTING'] = '1'
    # config['NO_TAKES'] = False
    tests.setup(context, config, app_factory=app_factory)

    if 'tobefixed' in feature.tags:
        feature.mark_skipped()

    if 'dbauth' in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if 'ldapauth' in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if 'amazons3' in feature.tags and not context.app.config.get(
            'AMAZON_CONTAINER_NAME', None):
        feature.mark_skipped()
Example #2
0
def before_feature(context, feature):
    config = getattr(setup_before_all, 'config', None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, 'config', None)
        app_factory = getattr(setup_before_scenario, 'app_factory', None)
    config = config or {}
    app_factory = app_factory or get_app

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    os.environ['BEHAVE_TESTING'] = '1'
    tests.setup(context, config, app_factory=app_factory)

    if 'tobefixed' in feature.tags:
        feature.mark_skipped()

    if 'dbauth' in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if 'ldapauth' in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if 'amazons3' in feature.tags and not context.app.config.get('AMAZON_CONTAINER_NAME', None):
        feature.mark_skipped()
Example #3
0
def before_scenario(context, scenario):
    config = {}
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False

    tests.setup(context=context, config=config, app_factory=get_app)
    context.headers = [
        ('Content-Type', 'application/json'),
        ('Origin', 'localhost')
    ]

    if 'dbauth' in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if 'ldapauth' in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        setup_auth_user(context)

    if scenario.status != 'skipped' and 'provider' in scenario.tags:
        setup_providers(context)

    if scenario.status != 'skipped' and 'vocabulary' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(os.path.dirname("features/steps/fixtures/")), "vocabularies.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
Example #4
0
def before_scenario(context, scenario):
    config = {}
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False

    tests.setup(context=context, config=config, app_factory=get_app)
    context.headers = [('Content-Type', 'application/json'),
                       ('Origin', 'localhost')]

    if 'dbauth' in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if 'ldapauth' in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        setup_auth_user(context)

    if scenario.status != 'skipped' and 'provider' in scenario.tags:
        setup_providers(context)

    if scenario.status != 'skipped' and 'vocabulary' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "vocabularies.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
Example #5
0
def before_feature(context, feature):
    config = {}
    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS
        config['AMAZON_SERVER'] = AMAZON_SERVER
        config['AMAZON_PROXY_SERVER'] = AMAZON_PROXY_SERVER
        config['AMAZON_URL_GENERATOR'] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    os.environ['BEHAVE_TESTING'] = '1'
    tests.setup(context, config)

    if 'tobefixed' in feature.tags:
        feature.mark_skipped()

    if 'dbauth' in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if 'ldapauth' in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if 'amazons3' in feature.tags and not context.app.config.get(
            'AMAZON_CONTAINER_NAME', None):
        feature.mark_skipped()
Example #6
0
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            self.app.data.insert('users', [{
                '_id': 123,
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**',
                'byline': 'E Harvey'
            }])
            self.app.data.insert('desks', [{'_id': 1, 'name': 'new zealand'}])
            self.app.data.insert(
                'vocabularies',
                [{
                    '_id':
                    'locators',
                    'items': [{
                        'is_active': True,
                        'name': 'ADV',
                        'qcode': 'ADV',
                        'group': ''
                    }]
                }, {
                    '_id': 'priority',
                    'items': [{
                        'is_active': True,
                        'name': 'Urgent',
                        'qcode': '3'
                    }]
                }])

            self.provider = {'name': 'Test', 'config': {'formatted': True}}
Example #7
0
 def setUp(self):
     setup(context=self)
     setup_notification(context=self)
     mock_logger = logging.getLogger("test")
     self.mock_logger_handler = MockLoggingHandler()
     mock_logger.addHandler(self.mock_logger_handler)
     errors.logger = mock_logger
     errors.notifiers = []
     self.provider = {"name": "TestProvider"}
Example #8
0
 def setUp(self):
     setup(context=self)
     setup_notification(context=self)
     mock_logger = logging.getLogger('test')
     self.mock_logger_handler = MockLoggingHandler()
     mock_logger.addHandler(self.mock_logger_handler)
     errors.logger = mock_logger
     errors.notifiers = []
     self.provider = {'name': 'TestProvider'}
Example #9
0
def setup_before_scenario(context, scenario, config, app_factory):
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False

    tests.setup(context, config, app_factory, bool(config))

    if context.app:
        # reset to False.
        context.app.config.update({'NO_TAKES': False})

    context.headers = [('Content-Type', 'application/json'),
                       ('Origin', 'localhost')]

    if 'dbauth' in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if 'ldapauth' in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if 'amazons3' in scenario.tags and not context.app.config.get(
            'AMAZON_CONTAINER_NAME', None):
        scenario.mark_skipped()

    if 'alchemy' in scenario.tags and not context.app.config.get(
            'KEYWORDS_KEY_API'):
        scenario.mark_skipped()

    if 'clean_snapshots' in scenario.tags:
        tests.use_snapshot.cache.clear()

    setup_search_provider(context.app)

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        setup_auth_user(context)

    if scenario.status != 'skipped' and 'provider' in scenario.tags:
        setup_providers(context)

    if scenario.status != 'skipped' and 'vocabulary' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "vocabularies.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'content_type' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "content_types.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
 def setUp(self):
     setup(context=self)
     with self.app.app_context():
         provider = {"name": "Test"}
         dirname = os.path.dirname(os.path.realpath(__file__))
         fixture = os.path.join(dirname, "fixtures", self.filename)
         with open(fixture, mode="rb") as f:
             bytes = f.read()
         parser = rfc822Parser()
         self.items = parser.parse_email([(1, bytes)], provider)
 def setUp(self):
     setup(context=self)
     with self.app.app_context():
         provider = {'name': 'Test'}
         dirname = os.path.dirname(os.path.realpath(__file__))
         fixture = os.path.join(dirname, 'fixtures', self.filename)
         with open(fixture, mode='rb') as f:
             bytes = f.read()
         parser = rfc822Parser()
         self.items = parser.parse_email([(1, bytes)], provider)
 def setUp(self):
     setup(context=self)
     with self.app.app_context():
         provider = {'name': 'Test'}
         dirname = os.path.dirname(os.path.realpath(__file__))
         fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename))
         with open(fixture, mode='rb') as f:
             bytes = f.read()
         parser = EMailRFC822FeedParser()
         self.items = parser.parse([(1, bytes)], provider)
 def setUp(self):
     setup(context=self)
     with self.app.app_context():
         provider = {"name": "Test"}
         dirname = os.path.dirname(os.path.realpath(__file__))
         fixture = os.path.normpath(
             os.path.join(dirname, "../fixtures", self.filename))
         with open(fixture, mode="rb") as f:
             bytes = f.read()
         parser = EMailRFC822FeedParser()
         self.items = parser.parse([(1, bytes)], provider)
Example #14
0
def before_all(context):
    config = {}
    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS

    tests.setup(context=context, config=config, app_factory=get_app)
    os.environ['BEHAVE_TESTING'] = '1'
Example #15
0
def setup_before_scenario(context, scenario, config, app_factory):
    if scenario.status != "skipped" and "notesting" in scenario.tags:
        config["SUPERDESK_TESTING"] = False

    tests.setup(context, config, app_factory, bool(config))

    context.headers = [("Content-Type", "application/json"),
                       ("Origin", "localhost")]

    if "dbauth" in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if "ldapauth" in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if "alchemy" in scenario.tags and not context.app.config.get(
            "KEYWORDS_KEY_API"):
        scenario.mark_skipped()

    if "clean_snapshots" in scenario.tags:
        tests.use_snapshot.cache.clear()

    setup_search_provider(context.app)

    if scenario.status != "skipped" and "auth" in scenario.tags:
        setup_auth_user(context)

    if scenario.status != "skipped" and "provider" in scenario.tags:
        setup_providers(context)

    if scenario.status != "skipped" and "vocabulary" in scenario.tags:
        with context.app.app_context():
            cmd = AppPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "vocabularies.json")
            cmd.run(filename)

    if scenario.status != "skipped" and "content_type" in scenario.tags:
        with context.app.app_context():
            cmd = AppPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "content_types.json")
            cmd.run(filename)

    if scenario.status != "skipped" and "notification" in scenario.tags:
        tests.setup_notification(context)

    if scenario.status != "skipped" and "app_init" in scenario.tags:
        with context.app.app_context():
            command = AppInitializeWithDataCommand()
            command.run()
Example #16
0
def setup_before_scenario(context, scenario, config, app_factory):
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False

    # TODO: Temp fix for DATE_FORMAT. This will be removed when superdesk will allow to specify custom test settings.
    config['DATE_FORMAT'] = DATE_FORMAT

    tests.setup(context, config, app_factory, bool(config))

    context.headers = [('Content-Type', 'application/json'),
                       ('Origin', 'localhost')]

    if 'amazons3' in scenario.tags and not context.app.config.get(
            'AMAZON_CONTAINER_NAME', None):
        scenario.mark_skipped()

    if 'alchemy' in scenario.tags and not context.app.config.get(
            'KEYWORDS_KEY_API'):
        scenario.mark_skipped()

    if 'clean_snapshots' in scenario.tags:
        tests.use_snapshot.cache.clear()

    setup_search_provider(context.app)

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        setup_auth_user(context)

    if scenario.status != 'skipped' and 'consumer_auth' in scenario.tags:
        setup_auth_consumer(context, test_consumer)

    if scenario.status != 'skipped' and 'provider' in scenario.tags:
        setup_providers(context)

    if scenario.status != 'skipped' and 'vocabulary' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "vocabularies.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'content_type' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(
                os.path.abspath(os.path.dirname("features/steps/fixtures/")),
                "content_types.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
def before_scenario(context, scenario):
    config = {}
    tests.setup(context, config)
    context.headers = [
        ('Content-Type', 'application/json'),
        ('Origin', 'localhost')
    ]

    if 'auth' in scenario.tags:
        tests.setup_auth_user(context)

    if 'provider' in scenario.tags:
        tests.setup_providers(context)
def before_scenario(context, scenario):
    config = {}
    tests.setup(context, config)
    context.headers = [('Content-Type', 'application/json'),
                       ('Origin', 'localhost')]

    if 'auth' in scenario.tags:
        tests.setup_auth_user(context)

    if 'provider' in scenario.tags:
        setup_providers(context)

    if 'notification' in scenario.tags:
        tests.setup_notification(context)
Example #19
0
    def setUpForChildren(self):
        """Run this `setUp` stuff for each children.

        Configure new `app` for each test.
        """
        setup.reset = True
        setup(self)

        self.ctx = self.app.app_context()
        self.ctx.push()

        def clean_ctx():
            if self.ctx:
                self.ctx.pop()

        self.addCleanup(clean_ctx)
Example #20
0
def setup_before_all(context, config, app_factory):
    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS
        config['AMAZON_SERVER'] = AMAZON_SERVER
        config['AMAZON_PROXY_SERVER'] = AMAZON_PROXY_SERVER
        config['AMAZON_URL_GENERATOR'] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    tests.setup(context=context, config=config, app_factory=app_factory)
    os.environ['BEHAVE_TESTING'] = '1'
Example #21
0
def setup_before_all(context, config, app_factory):
    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS
        config['AMAZON_SERVER'] = AMAZON_SERVER
        config['AMAZON_PROXY_SERVER'] = AMAZON_PROXY_SERVER
        config['AMAZON_URL_GENERATOR'] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    tests.setup(context=context, config=config, app_factory=app_factory)
    os.environ['BEHAVE_TESTING'] = '1'
Example #22
0
def setup_before_scenario(context, scenario, config, app_factory):
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False
    tests.setup(context, config, app_factory, bool(config))

    context.headers = [
        ('Content-Type', 'application/json'),
        ('Origin', 'localhost')
    ]

    if 'dbauth' in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if 'ldapauth' in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if 'amazons3' in scenario.tags and not context.app.config.get('AMAZON_CONTAINER_NAME', None):
        scenario.mark_skipped()

    if 'alchemy' in scenario.tags and not context.app.config.get('KEYWORDS_KEY_API'):
        scenario.mark_skipped()

    if 'clean_snapshots' in scenario.tags:
        tests.use_snapshot.cache.clear()

    setup_search_provider(context.app)

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        setup_auth_user(context)

    if scenario.status != 'skipped' and 'provider' in scenario.tags:
        setup_providers(context)

    if scenario.status != 'skipped' and 'vocabulary' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(os.path.dirname("features/steps/fixtures/")), "vocabularies.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'content_type' in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(os.path.dirname("features/steps/fixtures/")), "content_types.json")
            cmd.run(filename)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
Example #23
0
    def setUpForChildren(self):
        """Run this `setUp` stuff for each children."""
        config = {
            'INSTALLED_APPS': INSTALLED_APPS,
            'ELASTICSEARCH_FORCE_REFRESH': True,
        }

        setup(self, config=config, app_factory=get_app)

        self.ctx = self.app.app_context()
        self.ctx.push()

        def clean_ctx():
            if self.ctx:
                self.ctx.pop()

        self.addCleanup(clean_ctx)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            self.app.data.insert('users', [{
                '_id': 123,
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**',
                'byline': 'E Harvey'
            }])
            self.app.data.insert('desks', [{'_id': 1, 'name': 'new zealand'}])
            self.app.data.insert('vocabularies', [{'_id': 'locators',
                                                  'items': [{'is_active': True,
                                                             'name': 'ADV', 'qcode': 'ADV', 'group': ''}]},
                                                  {'_id': 'priority', 'items': [{'is_active': True,
                                                                                 'name': 'Urgent', 'qcode': '3'}]}])

            self.provider = {'name': 'Test', 'config': {'formatted': True}}
Example #25
0
def before_scenario(context, scenario):
    config = {}
    if scenario.status != "skipped" and "notesting" in scenario.tags:
        config["SUPERDESK_TESTING"] = False

    tests.setup(context, config)
    context.headers = [("Content-Type", "application/json"), ("Origin", "localhost")]

    if "dbauth" in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if scenario.status != "skipped" and "auth" in scenario.tags:
        tests.setup_auth_user(context)

    if scenario.status != "skipped" and "provider" in scenario.tags:
        setup_providers(context)

    if scenario.status != "skipped" and "notification" in scenario.tags:
        tests.setup_notification(context)
Example #26
0
    def setUpForChildren(self):
        """Run this `setUp` stuff for each children."""
        config = {
            'INSTALLED_APPS': INSTALLED_APPS,
            'ELASTICSEARCH_FORCE_REFRESH': True,
            'DEFAULT_TIMEZONE': 'Australia/Sydney',
            'MIN_BROADCAST_TEXT_WORD_COUNT': MIN_BROADCAST_TEXT_WORD_COUNT
        }

        setup(self, config=config, app_factory=get_app)

        self.ctx = self.app.app_context()
        self.ctx.push()

        def clean_ctx():
            if self.ctx:
                self.ctx.pop()

        self.addCleanup(clean_ctx)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            # mock one user:
            user_service = UsersService('users',
                                        backend=superdesk.get_backend())
            self.user_id = user_service.create([{
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**'
            }])[0]

            provider = {'name': 'Test'}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.join(dirname, 'fixtures', self.filename)
            with open(fixture, mode='rb') as f:
                bytes = f.read()
            parser = rfc822Parser()
            self.items = parser.parse_email([(1, bytes)], provider)
Example #28
0
def before_scenario(context, scenario):
    config = {}
    if scenario.status != 'skipped' and 'notesting' in scenario.tags:
        config['SUPERDESK_TESTING'] = False

    tests.setup(context, config)
    context.headers = [
        ('Content-Type', 'application/json'),
        ('Origin', 'localhost')
    ]

    if 'dbauth' in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if scenario.status != 'skipped' and 'auth' in scenario.tags:
        tests.setup_auth_user(context)

    if scenario.status != 'skipped' and 'notification' in scenario.tags:
        tests.setup_notification(context)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            # mock one user:
            user_service = UsersService(
                'users', backend=superdesk.get_backend())
            self.user_id = user_service.create([{
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**'
            }])[0]

            provider = {'name': 'Test'}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename))
            with open(fixture, mode='rb') as f:
                bytes = f.read()
            parser = EMailRFC822FeedParser()
            self.items = parser.parse([(1, bytes)], provider)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            # mock one user:
            user_service = UsersService("users",
                                        backend=superdesk.get_backend())
            self.user_id = user_service.create([{
                "name": "user",
                "user_type": "administrator",
                "email": "*****@*****.**"
            }])[0]

            provider = {"name": "Test"}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.normpath(
                os.path.join(dirname, "../fixtures", self.filename))
            with open(fixture, mode="rb") as f:
                bytes = f.read()
            parser = EMailRFC822FeedParser()
            self.items = parser.parse([(1, bytes)], provider)
Example #31
0
def setup_before_scenario(context, scenario, config, app_factory):
    if scenario.status != "skipped" and "notesting" in scenario.tags:
        config["SUPERDESK_TESTING"] = False
    tests.setup(context, config, app_factory, bool(config))

    context.headers = [("Content-Type", "application/json"), ("Origin", "localhost")]

    if "dbauth" in scenario.tags and LDAP_SERVER:
        scenario.mark_skipped()

    if "ldapauth" in scenario.tags and not LDAP_SERVER:
        scenario.mark_skipped()

    if "amazons3" in scenario.tags and not context.app.config.get("AMAZON_CONTAINER_NAME", None):
        scenario.mark_skipped()

    if "alchemy" in scenario.tags and not context.app.config.get("KEYWORDS_KEY_API"):
        scenario.mark_skipped()

    setup_search_provider(context.app)

    if scenario.status != "skipped" and "auth" in scenario.tags:
        setup_auth_user(context)

    if scenario.status != "skipped" and "provider" in scenario.tags:
        setup_providers(context)

    if scenario.status != "skipped" and "vocabulary" in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(os.path.dirname("features/steps/fixtures/")), "vocabularies.json")
            cmd.run(filename)

    if scenario.status != "skipped" and "content_type" in scenario.tags:
        with context.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(os.path.dirname("features/steps/fixtures/")), "content_types.json")
            cmd.run(filename)

    if scenario.status != "skipped" and "notification" in scenario.tags:
        tests.setup_notification(context)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            self.app.data.insert(
                "users",
                [{
                    "_id": 123,
                    "name": "user",
                    "user_type": "administrator",
                    "email": "*****@*****.**",
                    "byline": "E Harvey",
                }],
            )
            self.app.data.insert("desks", [{"_id": 1, "name": "new zealand"}])
            self.app.data.insert(
                "vocabularies",
                [
                    {
                        "_id":
                        "locators",
                        "items": [{
                            "is_active": True,
                            "name": "ADV",
                            "qcode": "ADV",
                            "group": ""
                        }]
                    },
                    {
                        "_id":
                        "priority",
                        "items": [{
                            "is_active": True,
                            "name": "Urgent",
                            "qcode": "3"
                        }]
                    },
                ],
            )

            self.provider = {"name": "Test", "config": {"formatted": True}}
Example #33
0
def before_feature(context, feature):
    config = getattr(setup_before_all, 'config', None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, 'config', None)
        app_factory = getattr(setup_before_scenario, 'app_factory', None)
    config = config or {}
    app_factory = app_factory or get_app

    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS
        config['AMAZON_SERVER'] = AMAZON_SERVER
        config['AMAZON_PROXY_SERVER'] = AMAZON_PROXY_SERVER
        config['AMAZON_URL_GENERATOR'] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    os.environ['BEHAVE_TESTING'] = '1'
    tests.setup(context, config, app_factory=app_factory)

    if 'tobefixed' in feature.tags:
        feature.mark_skipped()

    if 'dbauth' in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if 'ldapauth' in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if 'amazons3' in feature.tags and not context.app.config.get(
            'AMAZON_CONTAINER_NAME', None):
        feature.mark_skipped()
Example #34
0
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            self.app.data.insert('users', [{
                '_id': 123,
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**',
                'byline': 'E Harvey'
            }])
            self.app.data.insert('desks', [{'_id': 1, 'name': 'new zealand'}])
            self.app.data.insert(
                'vocabularies',
                [{
                    '_id':
                    'locators',
                    'items': [{
                        'is_active': True,
                        'name': 'ADV',
                        'qcode': 'ADV',
                        'group': ''
                    }]
                }, {
                    '_id': 'priority',
                    'items': [{
                        'is_active': True,
                        'name': 'Urgent',
                        'qcode': '3'
                    }]
                }])

            provider = {'name': 'Test', 'config': {'formatted': True}}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.normpath(
                os.path.join(dirname, '../fixtures', self.filename))
            with open(fixture, mode='rb') as f:
                bytes = f.read()
            parser = EMailRFC822FeedParser()
            self.items = parser.parse([(1, bytes)], provider)
Example #35
0
def before_feature(context, feature):
    config = getattr(setup_before_all, 'config', None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, 'config', None)
        app_factory = getattr(setup_before_scenario, 'app_factory', None)
    config = config or {}
    app_factory = app_factory or get_app

    if AMAZON_CONTAINER_NAME:
        config['AMAZON_CONTAINER_NAME'] = AMAZON_CONTAINER_NAME
        config['AMAZON_ACCESS_KEY_ID'] = AMAZON_ACCESS_KEY_ID
        config['AMAZON_SECRET_ACCESS_KEY'] = AMAZON_SECRET_ACCESS_KEY
        config['AMAZON_REGION'] = AMAZON_REGION
        config['AMAZON_SERVE_DIRECT_LINKS'] = AMAZON_SERVE_DIRECT_LINKS
        config['AMAZON_S3_USE_HTTPS'] = AMAZON_S3_USE_HTTPS
        config['AMAZON_SERVER'] = AMAZON_SERVER
        config['AMAZON_PROXY_SERVER'] = AMAZON_PROXY_SERVER
        config['AMAZON_URL_GENERATOR'] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config['MAX_TRANSMIT_RETRY_ATTEMPT'] = 0
    os.environ['BEHAVE_TESTING'] = '1'
    tests.setup(context, config, app_factory=app_factory)

    if 'tobefixed' in feature.tags:
        feature.mark_skipped()

    if 'dbauth' in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if 'ldapauth' in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if 'amazons3' in feature.tags and not context.app.config.get('AMAZON_CONTAINER_NAME', None):
        feature.mark_skipped()
Example #36
0
def before_feature(context, feature):
    config = getattr(setup_before_all, "config", None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, "config", None)
        app_factory = getattr(setup_before_scenario, "app_factory", None)
    config = config or {}
    app_factory = app_factory or get_app

    if AMAZON_CONTAINER_NAME:
        config["AMAZON_CONTAINER_NAME"] = AMAZON_CONTAINER_NAME
        config["AMAZON_ACCESS_KEY_ID"] = AMAZON_ACCESS_KEY_ID
        config["AMAZON_SECRET_ACCESS_KEY"] = AMAZON_SECRET_ACCESS_KEY
        config["AMAZON_REGION"] = AMAZON_REGION
        config["AMAZON_SERVE_DIRECT_LINKS"] = AMAZON_SERVE_DIRECT_LINKS
        config["AMAZON_S3_USE_HTTPS"] = AMAZON_S3_USE_HTTPS
        config["AMAZON_SERVER"] = AMAZON_SERVER
        config["AMAZON_PROXY_SERVER"] = AMAZON_PROXY_SERVER
        config["AMAZON_URL_GENERATOR"] = AMAZON_URL_GENERATOR

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config["MAX_TRANSMIT_RETRY_ATTEMPT"] = 0
    os.environ["BEHAVE_TESTING"] = "1"
    tests.setup(context, config, app_factory=app_factory)

    if "tobefixed" in feature.tags:
        feature.mark_skipped()

    if "dbauth" in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if "ldapauth" in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()

    if "amazons3" in feature.tags and not context.app.config.get("AMAZON_CONTAINER_NAME", None):
        feature.mark_skipped()
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            # mock one user:
            user_service = UsersService('users',
                                        backend=superdesk.get_backend())
            self.user_id = user_service.create([{
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**'
            }])[0]

            provider = {'name': 'Test'}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.normpath(
                os.path.join(dirname, '../fixtures', self.filename))
            with open(fixture, mode='rb') as f:
                data = [(1, f.read())]
            parser = EMailRFC822FeedParser()
            self.items = parser.parse(data, provider)
            instance = EmailBelgaFeedingService()

            instance.save_attachment(data, self.items)
    def setUp(self):
        setup(context=self)
        with self.app.app_context():
            self.app.data.insert('users', [{
                '_id': 123,
                'name': 'user',
                'user_type': 'administrator',
                'email': '*****@*****.**'
            }])
            self.app.data.insert('desks', [{'_id': 1, 'name': 'new zealand'}])
            self.app.data.insert('vocabularies', [{'_id': 'locators',
                                                  'items': [{'is_active': True,
                                                             'name': 'ADV', 'qcode': 'ADV', 'group': ''}]},
                                                  {'_id': 'priority', 'items': [{'is_active': True,
                                                                                 'name': 'Urgent', 'qcode': '3'}]}])

            provider = {'name': 'Test', 'config': {'formatted': True}}
            dirname = os.path.dirname(os.path.realpath(__file__))
            fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename))
            with open(fixture, mode='rb') as f:
                bytes = f.read()
            parser = EMailRFC822FeedParser()
            self.items = parser.parse([(1, bytes)], provider)
Example #39
0
def get_test_superdesk_app(extra_config=None):
    """
    Create and return configured test superdesk flask app.
    :param extra_config: extra settings
    :return: eve.flaskapp.Eve
    """
    test_config = {
        'MONGO_URI': get_mongo_uri('MONGO_URI', MONGO_DB),
        'ELASTICSEARCH_INDEX': ELASTICSEARCH_INDEX,
        'AUTH_SERVER_SHARED_SECRET': AUTH_SERVER_SHARED_SECRET,
    }
    if extra_config:
        test_config.update(extra_config)

    def context():
        pass

    context.app = None
    context.ctx = None
    context.client = None
    setup(context=context, config=test_config, app_factory=get_sd_app)

    return context.app
Example #40
0
def before_feature(context, feature):
    config = getattr(setup_before_all, "config", None)
    if config is not None:
        app_factory = setup_before_all.app_factory
    else:
        # superdesk-aap don't use "setup_before_all" already
        config = getattr(setup_before_scenario, "config", None)
        app_factory = getattr(setup_before_scenario, "app_factory", None)
    config = deepcopy(config or {})
    app_factory = app_factory or get_app

    # set the MAX_TRANSMIT_RETRY_ATTEMPT to zero so that transmit does not retry
    config["MAX_TRANSMIT_RETRY_ATTEMPT"] = 0
    os.environ["BEHAVE_TESTING"] = "1"
    tests.setup(context, config, app_factory=app_factory)

    if "tobefixed" in feature.tags:
        feature.mark_skipped()

    if "dbauth" in feature.tags and LDAP_SERVER:
        feature.mark_skipped()

    if "ldapauth" in feature.tags and not LDAP_SERVER:
        feature.mark_skipped()
def before_all(context):
    tests.setup(context)
Example #42
0
 def setUp(self):
     setup(self, app_factory=get_app)
     self.ctx = self.app.app_context()
     self.ctx.push()
 def setUp(self):
     setup(context=self)
Example #44
0
 def setUp(self):
     setup(context=self)
Example #45
0
 def setUp(self):
     setup(context=self)
     setup_providers(self)
Example #46
0
def step_impl_given_config(context):
    tests.setup(context, json.loads(context.text))
    tests.setup_auth_user(context)
Example #47
0
def step_impl_given_config(context):
    tests.setup(context, json.loads(context.text))
    tests.setup_auth_user(context)
Example #48
0
def before_all(context):
    tests.setup(context=context, app_factory=get_app)
    os.environ['BEHAVE_TESTING'] = '1'
Example #49
0
def before_all(context):
    tests.setup(context=context, app_factory=get_app)
    os.environ['BEHAVE_TESTING'] = '1'
Example #50
0
def before_all(context):
    tests.setup(context)
    os.environ['BEHAVE_TESTING'] = '1'
Example #51
0
def before_all(context):
    tests.setup(context)
 def setUp(self):
     setup(context=self)
     setup_providers(self)