Mercurial > bzapi
changeset 11:f7a14f8868e9
added more tests
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Wed, 23 Dec 2009 17:00:31 -0800 |
parents | 2731713f61a8 |
children | 4c4a2aba5383 |
files | test.py |
diffstat | 1 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test.py Wed Dec 23 16:12:27 2009 -0800 +++ b/test.py Wed Dec 23 17:00:31 2009 -0800 @@ -47,13 +47,43 @@ date = bzapi.datetime_from_rfc1123('Wed, 23 Dec 2009 20:42:59 GMT') self.assertEqual(str(date), '2009-12-23 20:42:59') - def test_bzapi_removes_dots_from_config(self): + def _get_basic_fake_api(self): urllib2 = FakeUrllib2() urllib2.set_url('http://foo/latest/configuration?', FAKE_CONFIG) api = bzapi.BugzillaApi('http://foo/latest', FakeCollection(), urllib2=urllib2) + return api + def test_bzapi_raises_err_on_bad_component(self): + api = self._get_basic_fake_api() + self.assertRaises(ValueError, + api.get, + '/blah', + product='Mozilla Labs', + component='nonexistent') + + def test_bzapi_raises_err_on_bad_product(self): + api = self._get_basic_fake_api() + self.assertRaises(ValueError, + api.get, + '/blah', + product='nonexistent') + self.assertRaises(ValueError, + api.get, + '/blah', + product='Mozilla Labs', + component='nonexistent') + + def test_bzapi_validates_product_and_component(self): + api = self._get_basic_fake_api() + api._urllib2.set_url('http://foo/latest/stuff?product=Mozilla+Labs&' + 'component=Jetpack', + {}) + api.get('/stuff', product='Mozilla Labs', component='Jetpack') + + def test_bzapi_removes_dots_from_config(self): + api = self._get_basic_fake_api() self.assertTrue('addons_DOT_mozilla_DOT_org' in api.config['product']) if __name__ == '__main__':