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()
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()
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)
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)
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()
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}}
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"}
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'}
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)
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'
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()
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)
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)
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'
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)
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}}
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)
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)
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)
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}}
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(): 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)
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 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)
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
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)
def setUp(self): setup(self, app_factory=get_app) self.ctx = self.app.app_context() self.ctx.push()
def setUp(self): setup(context=self)
def setUp(self): setup(context=self) setup_providers(self)
def step_impl_given_config(context): tests.setup(context, json.loads(context.text)) tests.setup_auth_user(context)
def before_all(context): tests.setup(context=context, app_factory=get_app) os.environ['BEHAVE_TESTING'] = '1'
def before_all(context): tests.setup(context) os.environ['BEHAVE_TESTING'] = '1'