Ejemplo n.º 1
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)
Ejemplo n.º 2
0
    def test_get_subscribers_by_filter_condition(self):
        filter_condition1 = {'field': 'urgency', 'operator': 'in', 'value': '2'}
        filter_condition2 = {'field': 'urgency', 'operator': 'in', 'value': '1'}
        filter_condition3 = {'field': 'headline', 'operator': 'like', 'value': 'tor'}
        filter_condition4 = {'field': 'urgency', 'operator': 'nin', 'value': '3'}

        with self.app.app_context():
            cmd = VocabulariesPopulateCommand()
            filename = os.path.join(os.path.abspath(
                os.path.dirname("apps/prepopulate/data_initialization/vocabularies.json")), "vocabularies.json")
            cmd.run(filename)
            self.assertTrue(len(self.s._get_subscribers_by_filter_condition(filter_condition1)) == 1)
            self.assertTrue(len(self.s._get_subscribers_by_filter_condition(filter_condition2)) == 0)
            self.assertTrue(len(self.s._get_subscribers_by_filter_condition(filter_condition3)) == 2)
            self.assertTrue(len(self.s._get_subscribers_by_filter_condition(filter_condition4)) == 1)
Ejemplo n.º 3
0
 def test_check_similar(self):
     f = superdesk.get_resource_service('filter_conditions')
     filter_condition1 = {'field': 'urgency', 'operator': 'in', 'value': '2'}
     filter_condition2 = {'field': 'urgency', 'operator': 'in', 'value': '3'}
     filter_condition3 = {'field': 'urgency', 'operator': 'in', 'value': '1'}
     filter_condition4 = {'field': 'urgency', 'operator': 'in', 'value': '5'}
     filter_condition5 = {'field': 'urgency', 'operator': 'nin', 'value': '5'}
     filter_condition6 = {'field': 'headline', 'operator': 'like', 'value': 'tor'}
     with self.app.app_context():
         cmd = VocabulariesPopulateCommand()
         filename = os.path.join(os.path.abspath(
             os.path.dirname("apps/prepopulate/data_initialization/vocabularies.json")), "vocabularies.json")
         cmd.run(filename)
         self.assertTrue(len(f._check_similar(filter_condition1)) == 2)
         self.assertTrue(len(f._check_similar(filter_condition2)) == 1)
         self.assertTrue(len(f._check_similar(filter_condition3)) == 0)
         self.assertTrue(len(f._check_similar(filter_condition4)) == 3)
         self.assertTrue(len(f._check_similar(filter_condition5)) == 1)
         self.assertTrue(len(f._check_similar(filter_condition6)) == 1)