def test_create_release_with_beta_number_null(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') params = dict( product='Firefox', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=None, release_channel='Beta', throttle=1 ) res = service.create_release(**params) ok_(res) # but... params['beta_number'] = 0 assert_raises( MissingArgumentError, service.create_release, **params )
def test_get_featured(self): service = Releases(config=self.config) # ...................................................................... # Test 1: one product params = {"products": ["Firefox"]} res = service.get_featured(**params) res_expected = {"hits": {"Firefox": ["13.0b1", "15.0a1"]}, "total": 2} eq_(res, res_expected) # ...................................................................... # Test 2: several products, several versions params = {"products": ["Firefox", "FennecAndroid", "Thunderbird"]} res = service.get_featured(**params) res_expected = { "hits": {"Firefox": ["13.0b1", "15.0a1"], "FennecAndroid": ["15.0a1"], "Thunderbird": ["15.0a1"]}, "total": 4, } eq_(res, res_expected) # ...................................................................... # Test 3: an unknown product params = {"products": ["Unknown"]} res = service.get_featured(**params) res_expected = {"hits": {}, "total": 0} eq_(res, res_expected) # ...................................................................... # Test 4: all products res = service.get_featured() res_expected = { "hits": {"Firefox": ["13.0b1", "15.0a1"], "FennecAndroid": ["15.0a1"], "Thunderbird": ["15.0a1"]}, "total": 4, } eq_(res, res_expected)
def test_post_missing_argument_error(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') with pytest.raises(MissingArgumentError): service.post(product='', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=1, release_channel='Beta', throttle=1)
def test_get_channels(self): self._insert_release_channels() self._insert_product_release_channels() service = Releases(config=self.config) #...................................................................... # Test 1: one product params = { "products": ["Firefox"] } res = service.get_channels(**params) res_expected = { "Firefox": ["Beta", "Aurora", "Nightly", "ESR"] } eq_(res, res_expected) #...................................................................... # Test 2: several products params = { "products": ["Firefox", "FennecAndroid"] } res = service.get_channels(**params) res_expected = { "FennecAndroid": ["Aurora", "Nightly"], "Firefox": ["Beta", "Aurora", "Nightly", "ESR"] } eq_(res, res_expected) #...................................................................... # Test 3: an unknown product params = { "products": ["Unknown"] } res = service.get_channels(**params) res_expected = {} eq_(res, res_expected) #...................................................................... # Test 4: all products res = service.get_channels() res_expected = { "Thunderbird": ["Nightly"], "FennecAndroid": ["Aurora", "Nightly"], "Firefox": ["Beta", "Aurora", "Nightly", "ESR"] } eq_(res, res_expected)
def test_post(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') params = dict(product='Firefox', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=1, release_channel='Beta', throttle=1) res = service.post(**params) assert res
def test_post_missing_argument_error(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') with pytest.raises(MissingArgumentError): service.post( product='', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=1, release_channel='Beta', throttle=1 )
def test_create_release(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') params = dict( product='Firefox', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=1, release_channel='Beta', throttle=1 ) res = service.create_release(**params) ok_(res)
def test_get_featured(self): self._insert_release_channels() self._insert_product_release_channels() service = Releases(config=self.config) #...................................................................... # Test 1: one product params = { "products": ["Firefox"] } res = service.get_featured(**params) res_expected = { "hits": { "Firefox": ["13.0b1", "15.0a1"] }, "total": 2 } eq_(res, res_expected) #...................................................................... # Test 2: several products, several versions params = { "products": ["Firefox", "FennecAndroid", "Thunderbird"] } res = service.get_featured(**params) res_expected = { "hits": { "Firefox": ["13.0b1", "15.0a1"], "FennecAndroid": ["15.0a1"], "Thunderbird": ["15.0a1"] }, "total": 4 } eq_(res, res_expected) #...................................................................... # Test 3: an unknown product params = { "products": ["Unknown"] } res = service.get_featured(**params) res_expected = { "hits": {}, "total": 0 } eq_(res, res_expected) #...................................................................... # Test 4: all products res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1", "15.0a1"], "FennecAndroid": ["15.0a1"], "Thunderbird": ["15.0a1"] }, "total": 4 } eq_(res, res_expected)
def test_update_release_missingargumenterror(self): self._insert_release_channels() service = Releases(config=self.config) now = datetimeutil.utc_now() build_id = now.strftime('%Y%m%d%H%M') params = dict(product='', version='1.0', update_channel='beta', build_id=build_id, platform='Windows', beta_number=1, release_channel='Beta', throttle=1) assert_raises(MissingArgumentError, service.create_release, **params)
def test_update_featured(self): self._insert_release_channels() self._insert_product_release_channels() service = Releases(config=self.config) #...................................................................... # Test 1: one product, several versions params = { "Firefox": [ "15.0a1", "14.0a2", "13.0b1" ] } res = service.update_featured(**params) ok_(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1", "14.0a2", "15.0a1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["15.0a1"] }, "total": 5 } eq_(res, res_expected) #...................................................................... # Test 2: several products, several versions params = { "Firefox": [ "13.0b1" ], "FennecAndroid": [ "14.0a1" ] } res = service.update_featured(**params) ok_(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } eq_(res, res_expected) #...................................................................... # Test 3: an unknown product params = { "Unknown": [ "15.0a1" ] } res = service.update_featured(**params) ok_(not res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } eq_(res, res_expected) #...................................................................... # Test 4: an unknown product and an existing product params = { "Firefox": [ "14.0a2" ], "Unknown": [ "15.0a1" ] } res = service.update_featured(**params) ok_(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["14.0a2"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } eq_(res, res_expected) #...................................................................... # Test 4: an unknown version params = { "Firefox": [ "200.0a1" # that's like, in 2035, dude ] } res = service.update_featured(**params) ok_(res) res = service.get_featured() res_expected = { "hits": { "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 2 } eq_(res, res_expected)
def test_update_featured(self): service = Releases(config=self.config) #...................................................................... # Test 1: one product, several versions params = {"Firefox": ["15.0a1", "14.0a2", "13.0b1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1", "14.0a2", "15.0a1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["15.0a1"] }, "total": 5 } self.assertEqual(res, res_expected) #...................................................................... # Test 2: several products, several versions params = {"Firefox": ["13.0b1"], "FennecAndroid": ["14.0a1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } self.assertEqual(res, res_expected) #...................................................................... # Test 3: an unknown product params = {"Unknown": ["15.0a1"]} res = service.update_featured(**params) self.assertFalse(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } self.assertEqual(res, res_expected) #...................................................................... # Test 4: an unknown product and an existing product params = {"Firefox": ["14.0a2"], "Unknown": ["15.0a1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": { "Firefox": ["14.0a2"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 3 } self.assertEqual(res, res_expected) #...................................................................... # Test 4: an unknown version params = { "Firefox": [ "200.0a1" # that's like, in 2035, dude ] } res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": { "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"] }, "total": 2 } self.assertEqual(res, res_expected)
def test_update_featured(self): service = Releases(config=self.config) # ...................................................................... # Test 1: one product, several versions params = {"Firefox": ["15.0a1", "14.0a2", "13.0b1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": {"Firefox": ["13.0b1", "14.0a2", "15.0a1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["15.0a1"]}, "total": 5, } self.assertEqual(res, res_expected) # ...................................................................... # Test 2: several products, several versions params = {"Firefox": ["13.0b1"], "FennecAndroid": ["14.0a1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": {"Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]}, "total": 3, } self.assertEqual(res, res_expected) # ...................................................................... # Test 3: an unknown product params = {"Unknown": ["15.0a1"]} res = service.update_featured(**params) self.assertFalse(res) res = service.get_featured() res_expected = { "hits": {"Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]}, "total": 3, } self.assertEqual(res, res_expected) # ...................................................................... # Test 4: an unknown product and an existing product params = {"Firefox": ["14.0a2"], "Unknown": ["15.0a1"]} res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = { "hits": {"Firefox": ["14.0a2"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]}, "total": 3, } self.assertEqual(res, res_expected) # ...................................................................... # Test 4: an unknown version params = {"Firefox": ["200.0a1"]} # that's like, in 2035, dude res = service.update_featured(**params) self.assertTrue(res) res = service.get_featured() res_expected = {"hits": {"Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]}, "total": 2} self.assertEqual(res, res_expected)