Esempio n. 1
0
def when_we_login_as_user(context, username, password):
    user = {'username': username, 'password': password, 'is_active': True, 'needs_activation': False}

    if context.text:
        user.update(json.loads(context.text))

    tests.setup_auth_user(context, user)
Esempio n. 2
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 '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)
Esempio n. 3
0
def when_we_switch_user(context):
    user = {
        'username': '******',
        'password': '******',
        'is_active': True,
        'needs_activation': False
    }
    tests.setup_auth_user(context, user)
Esempio n. 4
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)
Esempio n. 5
0
def when_we_switch_user_of_type_user(context):
    user = {
        'username': '******',
        'password': '******',
        'is_active': True,
        'needs_activation': False,
        'user_type': 'user'
    }
    tests.setup_auth_user(context, user)
    set_placeholder(context, 'USERS_ID', str(context.user['_id']))
Esempio n. 6
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()
Esempio n. 7
0
    def test_default_pagination(self):
        setup_auth_user(self)
        self.app.data.insert('stages', [{
            'name': 'stage{}'.format(i)
        } for i in range(300)])

        response = self.client.get('/api/stages', headers=self.headers)
        self.assertEqual(200, response.status_code)

        data = json.loads(response.get_data())
        self.assertEqual(200, len(data['_items']))
        self.assertEqual(300, data['_meta']['total'])
    def test_default_pagination(self):
        setup_auth_user(self)
        self.app.data.insert("stages", [{
            "name": "stage{}".format(i)
        } for i in range(300)])

        response = self.client.get("/api/stages", headers=self.headers)
        self.assertEqual(200, response.status_code)

        data = json.loads(response.get_data())
        self.assertEqual(200, len(data["_items"]))
        self.assertEqual(300, data["_meta"]["total"])
Esempio n. 9
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)
Esempio n. 11
0
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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 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 "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)
Esempio n. 16
0
def when_we_switch_user(context):
    user = {'username': '******', 'password': '******'}
    tests.setup_auth_user(context, user)
Esempio n. 17
0
def step_impl_given_config(context):
    tests.setup(context, json.loads(context.text))
    tests.setup_auth_user(context)
Esempio n. 18
0
def when_we_switch_user(context):
    user = {'username': '******', 'password': '******'}
    tests.setup_auth_user(context, user)
Esempio n. 19
0
def step_impl_given_config(context):
    tests.setup(context, json.loads(context.text))
    tests.setup_auth_user(context)
Esempio n. 20
0
def when_we_setup_test_user(context):
    tests.setup_auth_user(context, test_user)
Esempio n. 21
0
def when_we_switch_user(context):
    user = {'username': '******', 'password': '******', 'is_active': True, 'needs_activation': False}
    tests.setup_auth_user(context, user)
Esempio n. 22
0
def when_we_switch_user_of_type_user(context):
    user = {'username': '******', 'password': '******', 'is_active': True, 'needs_activation': False,
            'user_type': 'user'}
    tests.setup_auth_user(context, user)
    set_placeholder(context, 'USERS_ID', str(context.user['_id']))
Esempio n. 23
0
def when_we_setup_test_user(context):
    tests.setup_auth_user(context, test_user)