Example #1
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {"signatures": "mysignature"}
        res = bugs.get(**params)
        res_expected = {
            "hits": [{
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            2
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2: several signatures with bugs
        params = {"signatures": ["mysignature", "js"]}
        res = bugs.get(**params)
        res_expected = {
            "hits": [{
                "id": 1,
                "signature": "sign1"
            }, {
                "id": 1,
                "signature": "js"
            }, {
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            4
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 3: a signature without bugs
        params = {"signatures": "unknown"}
        res = bugs.get(**params)
        res_expected = {"hits": [], "total": 0}

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        self.assertRaises(MissingOrBadArgumentError, bugs.get, **params)
Example #2
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {
            "signatures": "mysignature"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 2
        }
        eq_(res['total'], res_expected['total'])
        # by convert the hits to sets we can be certain order doesn't matter
        eq_(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']])
        )

        #......................................................................
        # Test 2: several signatures with bugs
        params = {
            "signatures": ["mysignature", "js"]
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 1,
                    "signature": "sign1"
                },
                {
                    "id": 1,
                    "signature": "js"
                },
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 4
        }

        eq_(res['total'], res_expected['total'])
        eq_(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']])
        )

        #......................................................................
        # Test 3: a signature without bugs
        params = {
            "signatures": "unknown"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }

        eq_(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        assert_raises(MissingArgumentError, bugs.get, **params)

        #......................................................................
        # Test 5: search by bug_ids argument
        params = {
            "bug_ids": ["1", "2"]
        }
        res = bugs.get(**params)

        # This is what we expect but because the results aren't sorted,
        # we can't expect them to come in in this order.
        res_expected = {
            'hits': [
                {'id': 1, 'signature': 'js'},
                {'id': 1, 'signature': 'sign1'},
                {'id': 2, 'signature': 'mysignature'}
            ],
            'total': 3
        }
        eq_(res['total'], res_expected['total'])
        assert len(res['hits']) == len(res_expected['hits'])
        for row in res_expected['hits']:
            ok_(row in res['hits'])
Example #3
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        # Test 1: a valid signature with 2 bugs
        params = {
            "signatures": "mysignature"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 2
        }
        assert res['total'] == res_expected['total']
        # by convert the hits to sets we can be certain order doesn't matter
        expected = set([(x['id'], x['signature']) for x in res_expected['hits']])
        assert set([(x['id'], x['signature']) for x in res['hits']]) == expected

        # Test 2: several signatures with bugs
        params = {
            "signatures": ["mysignature", "js"]
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 1,
                    "signature": "sign1"
                },
                {
                    "id": 1,
                    "signature": "js"
                },
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 4
        }

        assert res['total'] == res_expected['total']
        expected = set([(x['id'], x['signature']) for x in res_expected['hits']])
        assert set([(x['id'], x['signature']) for x in res['hits']]) == expected

        # Test 3: a signature without bugs
        params = {
            "signatures": "unknown"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }

        assert res == res_expected

        # Test 4: missing argument
        with pytest.raises(MissingArgumentError):
            bugs.get()

        # Test 5: search by bug_ids argument
        params = {
            "bug_ids": ["1", "2"]
        }
        res = bugs.get(**params)

        # This is what we expect but because the results aren't sorted,
        # we can't expect them to come in in this order.
        res_expected = {
            'hits': [
                {'id': 1, 'signature': 'js'},
                {'id': 1, 'signature': 'sign1'},
                {'id': 2, 'signature': 'mysignature'}
            ],
            'total': 3
        }
        assert res['total'] == res_expected['total']
        assert len(res['hits']) == len(res_expected['hits'])
        for row in res_expected['hits']:
            assert row in res['hits']
Example #4
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {
            "signatures": "mysignature"
        }
        res = bugs.post(**params)
        res_expected = {
            "hits": [
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 2
        }
        self.assertEqual(res['total'], res_expected['total'])
        # by convert the hits to sets we can be certain order doesn't matter
        self.assertEqual(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']])
        )

        #......................................................................
        # Test 2: several signatures with bugs
        params = {
            "signatures": ["mysignature", "js"]
        }
        res = bugs.post(**params)
        res_expected = {
            "hits": [
                {
                    "id": 1,
                    "signature": "sign1"
                },
                {
                    "id": 1,
                    "signature": "js"
                },
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 4
        }

        self.assertEqual(res['total'], res_expected['total'])
        self.assertEqual(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']])
        )

        #......................................................................
        # Test 3: a signature without bugs
        params = {
            "signatures": "unknown"
        }
        res = bugs.post(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        self.assertRaises(MissingArgumentError, bugs.post, **params)
Example #5
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {
            "signatures": "mysignature"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 2
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2: several signatures with bugs
        params = {
            "signatures": ["mysignature", "js"]
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [
                {
                    "id": 1,
                    "signature": "sign1"
                },
                {
                    "id": 1,
                    "signature": "js"
                },
                {
                    "id": 2,
                    "signature": "mysignature"
                },
                {
                    "id": 3,
                    "signature": "mysignature"
                }
            ],
            "total": 4
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 3: a signature without bugs
        params = {
            "signatures": "unknown"
        }
        res = bugs.get(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        self.assertRaises(MissingOrBadArgumentError, bugs.get, **params)
Example #6
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {"signatures": "mysignature"}
        res = bugs.post(**params)
        res_expected = {
            "hits": [{
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            2
        }
        eq_(res['total'], res_expected['total'])
        # by convert the hits to sets we can be certain order doesn't matter
        eq_(set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']]))

        #......................................................................
        # Test 2: several signatures with bugs
        params = {"signatures": ["mysignature", "js"]}
        res = bugs.post(**params)
        res_expected = {
            "hits": [{
                "id": 1,
                "signature": "sign1"
            }, {
                "id": 1,
                "signature": "js"
            }, {
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            4
        }

        eq_(res['total'], res_expected['total'])
        eq_(set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']]))

        #......................................................................
        # Test 3: a signature without bugs
        params = {"signatures": "unknown"}
        res = bugs.post(**params)
        res_expected = {"hits": [], "total": 0}

        eq_(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        assert_raises(MissingArgumentError, bugs.post, **params)

        #......................................................................
        # Test 5: search by bug_ids argument
        params = {"bug_ids": ["1", "2"]}
        res = bugs.post(**params)
        res_expected = {
            'hits': [{
                'id': 1,
                'signature': 'sign1'
            }, {
                'id': 1,
                'signature': 'js'
            }, {
                'id': 2,
                'signature': 'mysignature'
            }],
            "total":
            3
        }
        eq_(res, res_expected)
Example #7
0
    def test_get(self):
        bugs = Bugs(config=self.config)

        #......................................................................
        # Test 1: a valid signature with 2 bugs
        params = {"signatures": "mysignature"}
        res = bugs.post(**params)
        res_expected = {
            "hits": [{
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            2
        }
        self.assertEqual(res['total'], res_expected['total'])
        # by convert the hits to sets we can be certain order doesn't matter
        self.assertEqual(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']]))

        #......................................................................
        # Test 2: several signatures with bugs
        params = {"signatures": ["mysignature", "js"]}
        res = bugs.post(**params)
        res_expected = {
            "hits": [{
                "id": 1,
                "signature": "sign1"
            }, {
                "id": 1,
                "signature": "js"
            }, {
                "id": 2,
                "signature": "mysignature"
            }, {
                "id": 3,
                "signature": "mysignature"
            }],
            "total":
            4
        }

        self.assertEqual(res['total'], res_expected['total'])
        self.assertEqual(
            set([(x['id'], x['signature']) for x in res['hits']]),
            set([(x['id'], x['signature']) for x in res_expected['hits']]))

        #......................................................................
        # Test 3: a signature without bugs
        params = {"signatures": "unknown"}
        res = bugs.post(**params)
        res_expected = {"hits": [], "total": 0}

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: missing argument
        params = {}
        self.assertRaises(MissingArgumentError, bugs.post, **params)