Example #1
0
    def test_get_parameters(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {"signature": "mysig", "product": "WaterWolf", "version": "1.0"}
        params = search.get_parameters(**args)
        for i in ("signature", "product", "version"):
            ok_(i in params)
            ok_(isinstance(params[i], list))
            ok_(isinstance(params[i][0], SearchParam))
            eq_(params[i][0].operator, "")

        args = {"signature": "~js", "product": ["WaterWolf", "NightTrain"], "version": "=1.0"}
        params = search.get_parameters(**args)
        eq_(params["signature"][0].operator, "~")
        eq_(params["signature"][0].value, "js")
        eq_(params["product"][0].operator, "")
        # Test that params with no operator are stacked
        eq_(params["product"][0].value, ["WaterWolf", "NightTrain"])
        eq_(params["version"][0].operator, "")

        args = {"signature": ["~Mark", "$js"]}
        params = search.get_parameters(**args)
        eq_(params["signature"][0].operator, "~")
        eq_(params["signature"][0].value, "Mark")
        eq_(params["signature"][1].operator, "$")
        eq_(params["signature"][1].value, "js")

        args = {"build_id": [">20000101000000", "<20150101000000"]}
        params = search.get_parameters(**args)
        eq_(params["build_id"][0].operator, ">")
        eq_(params["build_id"][0].value, 20000101000000)
        eq_(params["build_id"][1].operator, "<")
        eq_(params["build_id"][1].value, 20150101000000)
Example #2
0
    def test_version_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {'version': ['38.0b']}
        params = search.get_parameters(**args)
        ok_('version' in params)
        eq_(len(params['version']), 1)
        eq_(params['version'][0].value, '38.0b')
        eq_(params['version'][0].operator, '$')
        ok_(not params['version'][0].operator_not)

        args = {'version': ['1.9b2', '1.9b', '!2.9b', '^.0b']}
        params = search.get_parameters(**args)
        ok_('version' in params)
        eq_(len(params['version']), 4)
        for param in params['version']:
            assert param.operator in ('$', '^', '')

            if param.operator == '$' and not param.operator_not:
                # starts with, this one was made up.
                eq_(param.value, '1.9b')
            elif param.operator == '$' and param.operator_not:
                # starts with, this one was made up.
                eq_(param.value, '2.9b')
            elif param.operator == '^':
                eq_(param.value, '.0b')
            elif param.operator == '':
                eq_(param.value, ['1.9b2'])
Example #3
0
    def test_get_parameters_date_defaults(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        now = datetimeutil.utc_now()

        # Test default values when nothing is passed
        params = search.get_parameters()
        ok_('date' in params)
        eq_(len(params['date']), 2)

        # Pass only the high value
        args = {
            'date': '<%s' % datetimeutil.date_to_string(now)
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<')
        eq_(params['date'][1].operator, '>=')
        eq_(params['date'][0].value.date(), now.date())
        eq_(
            params['date'][1].value.date(),
            now.date() - datetime.timedelta(days=7)
        )

        # Pass only the low value
        pasttime = now - datetime.timedelta(days=10)
        args = {
            'date': '>=%s' % datetimeutil.date_to_string(pasttime)
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<=')
        eq_(params['date'][1].operator, '>=')
        eq_(params['date'][0].value.date(), now.date())
        eq_(params['date'][1].value.date(), pasttime.date())

        # Pass the two values
        pasttime = now - datetime.timedelta(days=10)
        args = {
            'date': [
                '<%s' % datetimeutil.date_to_string(now),
                '>%s' % datetimeutil.date_to_string(pasttime),
            ]
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<')
        eq_(params['date'][1].operator, '>')
        eq_(params['date'][0].value.date(), now.date())
        eq_(params['date'][1].value.date(), pasttime.date())
    def test_get_parameters_date_defaults(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        now = datetimeutil.utc_now()

        # Test default values when nothing is passed
        params = search.get_parameters()
        ok_('date' in params)
        eq_(len(params['date']), 2)

        # Pass only the high value
        args = {
            'date': '<%s' % datetimeutil.date_to_string(now)
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<')
        eq_(params['date'][1].operator, '>=')
        eq_(params['date'][0].value.date(), now.date())
        eq_(
            params['date'][1].value.date(),
            now.date() - datetime.timedelta(days=7)
        )

        # Pass only the low value
        pasttime = now - datetime.timedelta(days=10)
        args = {
            'date': '>=%s' % datetimeutil.date_to_string(pasttime)
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<=')
        eq_(params['date'][1].operator, '>=')
        eq_(params['date'][0].value.date(), now.date())
        eq_(params['date'][1].value.date(), pasttime.date())

        # Pass the two values
        pasttime = now - datetime.timedelta(days=10)
        args = {
            'date': [
                '<%s' % datetimeutil.date_to_string(now),
                '>%s' % datetimeutil.date_to_string(pasttime),
            ]
        }
        params = search.get_parameters(**args)
        ok_('date' in params)
        eq_(len(params['date']), 2)
        eq_(params['date'][0].operator, '<')
        eq_(params['date'][1].operator, '>')
        eq_(params['date'][0].value.date(), now.date())
        eq_(params['date'][1].value.date(), pasttime.date())
Example #5
0
    def test_get_parameters(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {
            'signature': 'mysig',
            'product': 'WaterWolf',
            'version': '1.0',
        }
        params = search.get_parameters(**args)
        for i in ('signature', 'product', 'version'):
            ok_(i in params)
            ok_(isinstance(params[i], list))
            ok_(isinstance(params[i][0], SearchParam))
            eq_(params[i][0].operator, '')

        args = {
            'signature': '~js',
            'product': ['WaterWolf', 'NightTrain'],
            'process_type': '=crash',
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        eq_(params['signature'][0].value, 'js')
        eq_(params['product'][0].operator, '')
        # Test that params with no operator are stacked
        eq_(
            params['product'][0].value,
            ['WaterWolf', 'NightTrain']
        )
        eq_(params['process_type'][0].operator, '')

        args = {
            'signature': ['~Mark', '$js'],
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        eq_(params['signature'][0].value, 'Mark')
        eq_(params['signature'][1].operator, '$')
        eq_(params['signature'][1].value, 'js')

        args = {
            'build_id': ['>20000101000000', '<20150101000000'],
        }
        params = search.get_parameters(**args)
        eq_(params['build_id'][0].operator, '>')
        eq_(params['build_id'][0].value, 20000101000000)
        eq_(params['build_id'][1].operator, '<')
        eq_(params['build_id'][1].value, 20150101000000)
    def test_get_parameters(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {
            'signature': 'mysig',
            'product': 'WaterWolf',
            'version': '1.0',
        }
        params = search.get_parameters(**args)
        for i in ('signature', 'product', 'version'):
            ok_(i in params)
            ok_(isinstance(params[i], list))
            ok_(isinstance(params[i][0], SearchParam))
            eq_(params[i][0].operator, '')

        args = {
            'signature': '~js',
            'product': ['WaterWolf', 'NightTrain'],
            'version': '=1.0',
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        eq_(params['signature'][0].value, 'js')
        eq_(params['product'][0].operator, '')
        # Test that params with no operator are stacked
        eq_(
            params['product'][0].value,
            ['WaterWolf', 'NightTrain']
        )
        eq_(params['version'][0].operator, '')

        args = {
            'signature': ['~Mark', '$js'],
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        eq_(params['signature'][0].value, 'Mark')
        eq_(params['signature'][1].operator, '$')
        eq_(params['signature'][1].value, 'js')

        args = {
            'build_id': ['>20000101000000', '<20150101000000'],
        }
        params = search.get_parameters(**args)
        eq_(params['build_id'][0].operator, '>')
        eq_(params['build_id'][0].value, 20000101000000)
        eq_(params['build_id'][1].operator, '<')
        eq_(params['build_id'][1].value, 20150101000000)
Example #7
0
    def test_get_parameters(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'signature': 'mysig',
            'product': 'WaterWolf',
            'version': '1.0',
        }
        params = search.get_parameters(**args)
        for i in ('signature', 'product', 'version'):
            self.assertTrue(i in params)
            self.assertTrue(isinstance(params[i], list))
            self.assertTrue(isinstance(params[i][0], SearchParam))
            self.assertEqual(params[i][0].operator, '')

        args = {
            'signature': '~js',
            'product': ['WaterWolf', 'NightTrain'],
            'version': '=1.0',
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertEqual(params['signature'][0].value, 'js')
        self.assertEqual(params['product'][0].operator, '')
        # Test that params with no operator are stacked
        self.assertEqual(
            params['product'][0].value,
            ['WaterWolf', 'NightTrain']
        )
        self.assertEqual(params['version'][0].operator, '')

        args = {
            'signature': ['~Mark', '$js'],
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertEqual(params['signature'][0].value, 'Mark')
        self.assertEqual(params['signature'][1].operator, '$')
        self.assertEqual(params['signature'][1].value, 'js')

        args = {
            'build_id': ['>20000101000000', '<20150101000000'],
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['build_id'][0].operator, '>')
        self.assertEqual(params['build_id'][0].value, 20000101000000)
        self.assertEqual(params['build_id'][1].operator, '<')
        self.assertEqual(params['build_id'][1].value, 20150101000000)
Example #8
0
    def test_hang_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {"hang_type": "hang"}
        params = search.get_parameters(**args)
        ok_("hang_type" in params)
        eq_(len(params["hang_type"]), 1)
        eq_(params["hang_type"][0].value, [-1, 1])

        args = {"hang_type": "crash"}
        params = search.get_parameters(**args)
        ok_("hang_type" in params)
        eq_(len(params["hang_type"]), 1)
        eq_(params["hang_type"][0].value, [0])
Example #9
0
    def test_get_parameters_with_not(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {
            'signature': '!~mysig',
            'product': '!WaterWolf',
            'version': '1.0',
            'user_comments': '!__null__',
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        ok_(params['signature'][0].operator_not)
        eq_(params['signature'][0].value, 'mysig')

        eq_(params['product'][0].operator, '')
        ok_(params['product'][0].operator_not)

        eq_(params['version'][0].operator, '')
        ok_(not params['version'][0].operator_not)

        eq_(params['user_comments'][0].operator, '__null__')
        ok_(params['user_comments'][0].operator_not)
Example #10
0
    def test_get_parameters_with_not(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {
            'signature': '!~mysig',
            'product': '!WaterWolf',
            'version': '1.0',
            'user_comments': '!__null__',
        }
        params = search.get_parameters(**args)
        eq_(params['signature'][0].operator, '~')
        ok_(params['signature'][0].operator_not)
        eq_(params['signature'][0].value, 'mysig')

        eq_(params['product'][0].operator, '')
        ok_(params['product'][0].operator_not)

        eq_(params['version'][0].operator, '')
        ok_(not params['version'][0].operator_not)

        eq_(params['user_comments'][0].operator, '__null__')
        ok_(params['user_comments'][0].operator_not)
Example #11
0
    def test_get_parameters(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'signature': 'mysig',
            'product': 'WaterWolf',
            'version': '1.0',
        }
        params = search.get_parameters(**args)
        for i in ('signature', 'product', 'version'):
            self.assertTrue(i in params)
            self.assertTrue(isinstance(params[i], list))
            self.assertTrue(isinstance(params[i][0], SearchParam))
            self.assertEqual(params[i][0].operator, '')

        args = {
            'signature': '~js',
            'product': ['WaterWolf', 'NightTrain'],
            'version': '=1.0',
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertEqual(params['signature'][0].value, 'js')
        self.assertEqual(params['product'][0].operator, '')
        # Test that params with no operator are stacked
        self.assertEqual(params['product'][0].value,
                         ['WaterWolf', 'NightTrain'])
        self.assertEqual(params['version'][0].operator, '')

        args = {
            'signature': ['~Mark', '$js'],
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertEqual(params['signature'][0].value, 'Mark')
        self.assertEqual(params['signature'][1].operator, '$')
        self.assertEqual(params['signature'][1].value, 'js')

        args = {
            'build_id': ['>20000101000000', '<20150101000000'],
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['build_id'][0].operator, '>')
        self.assertEqual(params['build_id'][0].value, 20000101000000)
        self.assertEqual(params['build_id'][1].operator, '<')
        self.assertEqual(params['build_id'][1].value, 20150101000000)
Example #12
0
    def test_hang_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {'hang_type': 'hang'}
        params = search.get_parameters(**args)
        ok_('hang_type' in params)
        eq_(len(params['hang_type']), 1)
        eq_(params['hang_type'][0].value, [-1, 1])

        args = {'hang_type': 'crash'}
        params = search.get_parameters(**args)
        ok_('hang_type' in params)
        eq_(len(params['hang_type']), 1)
        eq_(params['hang_type'][0].value, [0])
    def test_hang_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'hang_type': 'hang'
        }
        params = search.get_parameters(**args)
        ok_('hang_type' in params)
        eq_(len(params['hang_type']), 1)
        eq_(params['hang_type'][0].value, [-1, 1])

        args = {
            'hang_type': 'crash'
        }
        params = search.get_parameters(**args)
        ok_('hang_type' in params)
        eq_(len(params['hang_type']), 1)
        eq_(params['hang_type'][0].value, [0])
Example #14
0
    def test_get_parameters_date_defaults(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        now = datetimeutil.utc_now()

        # Test default values when nothing is passed
        params = search.get_parameters()
        ok_("date" in params)
        eq_(len(params["date"]), 2)

        # Pass only the high value
        args = {"date": "<%s" % datetimeutil.date_to_string(now)}
        params = search.get_parameters(**args)
        ok_("date" in params)
        eq_(len(params["date"]), 2)
        eq_(params["date"][0].operator, "<")
        eq_(params["date"][1].operator, ">=")
        eq_(params["date"][0].value.date(), now.date())
        eq_(params["date"][1].value.date(), now.date() - datetime.timedelta(days=7))

        # Pass only the low value
        pasttime = now - datetime.timedelta(days=10)
        args = {"date": ">=%s" % datetimeutil.date_to_string(pasttime)}
        params = search.get_parameters(**args)
        ok_("date" in params)
        eq_(len(params["date"]), 2)
        eq_(params["date"][0].operator, "<=")
        eq_(params["date"][1].operator, ">=")
        eq_(params["date"][0].value.date(), now.date())
        eq_(params["date"][1].value.date(), pasttime.date())

        # Pass the two values
        pasttime = now - datetime.timedelta(days=10)
        args = {"date": ["<%s" % datetimeutil.date_to_string(now), ">%s" % datetimeutil.date_to_string(pasttime)]}
        params = search.get_parameters(**args)
        ok_("date" in params)
        eq_(len(params["date"]), 2)
        eq_(params["date"][0].operator, "<")
        eq_(params["date"][1].operator, ">")
        eq_(params["date"][0].value.date(), now.date())
        eq_(params["date"][1].value.date(), pasttime.date())
Example #15
0
    def test_process_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {"process_type": "browser"}
        params = search.get_parameters(**args)
        ok_("process_type" in params)
        eq_(len(params["process_type"]), 1)
        eq_(params["process_type"][0].value, [""])
        eq_(params["process_type"][0].operator, "__null__")
        eq_(params["process_type"][0].operator_not, False)
    def test_process_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'process_type': 'browser'
        }
        params = search.get_parameters(**args)
        ok_('process_type' in params)
        eq_(len(params['process_type']), 1)
        eq_(params['process_type'][0].value, [''])
        eq_(params['process_type'][0].operator, '__null__')
        eq_(params['process_type'][0].operator_not, False)
Example #17
0
    def test_process_type_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {'process_type': 'browser'}
        params = search.get_parameters(**args)
        ok_('process_type' in params)
        eq_(len(params['process_type']), 1)
        eq_(params['process_type'][0].value, [''])
        eq_(params['process_type'][0].operator, '__null__')
        eq_(params['process_type'][0].operator_not, False)
Example #18
0
    def test_version_parameter_correction(self):
        with _get_config_manager().context() as config:
            search = SearchBase(
                config=config,
                fields=SUPERSEARCH_FIELDS_MOCKED_RESULTS,
            )

        args = {
            'version': ['38.0b']
        }
        params = search.get_parameters(**args)
        ok_('version' in params)
        eq_(len(params['version']), 1)
        eq_(params['version'][0].value, '38.0b')
        eq_(params['version'][0].operator, '$')
        ok_(not params['version'][0].operator_not)

        args = {
            'version': ['1.9b2', '1.9b', '!2.9b', '^.0b']
        }
        params = search.get_parameters(**args)
        ok_('version' in params)
        eq_(len(params['version']), 4)
        for param in params['version']:
            assert param.operator in ('$', '^', '')

            if param.operator == '$' and not param.operator_not:
                # starts with, this one was made up.
                eq_(param.value, '1.9b')
            elif param.operator == '$' and param.operator_not:
                # starts with, this one was made up.
                eq_(param.value, '2.9b')
            elif param.operator == '^':
                eq_(param.value, '.0b')
            elif param.operator == '':
                eq_(param.value, ['1.9b2'])
Example #19
0
    def test_get_parameters_with_not(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {"signature": "!~mysig", "product": "!WaterWolf", "version": "1.0", "user_comments": "!__null__"}
        params = search.get_parameters(**args)
        eq_(params["signature"][0].operator, "~")
        ok_(params["signature"][0].operator_not)
        eq_(params["signature"][0].value, "mysig")

        eq_(params["product"][0].operator, "")
        ok_(params["product"][0].operator_not)

        eq_(params["version"][0].operator, "")
        ok_(not params["version"][0].operator_not)

        eq_(params["user_comments"][0].operator, "__null__")
        ok_(params["user_comments"][0].operator_not)
Example #20
0
    def test_get_parameters_with_not(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'signature': '!~mysig',
            'product': '!WaterWolf',
            'version': '1.0',
            'user_comments': '!__null__',
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertTrue(params['signature'][0].operator_not)
        self.assertEqual(params['signature'][0].value, 'mysig')

        self.assertEqual(params['product'][0].operator, '')
        self.assertTrue(params['product'][0].operator_not)

        self.assertEqual(params['version'][0].operator, '')
        self.assertFalse(params['version'][0].operator_not)

        self.assertEqual(params['user_comments'][0].operator, '__null__')
        self.assertTrue(params['user_comments'][0].operator_not)
Example #21
0
    def test_get_parameters_with_not(self):
        with _get_config_manager().context() as config:
            search = SearchBase(config=config)

        args = {
            'signature': '!~mysig',
            'product': '!WaterWolf',
            'version': '1.0',
            'user_comments': '!__null__',
        }
        params = search.get_parameters(**args)
        self.assertEqual(params['signature'][0].operator, '~')
        self.assertTrue(params['signature'][0].operator_not)
        self.assertEqual(params['signature'][0].value, 'mysig')

        self.assertEqual(params['product'][0].operator, '')
        self.assertTrue(params['product'][0].operator_not)

        self.assertEqual(params['version'][0].operator, '')
        self.assertFalse(params['version'][0].operator_not)

        self.assertEqual(params['user_comments'][0].operator, '__null__')
        self.assertTrue(params['user_comments'][0].operator_not)