| |
@@ -6,11 +6,10 @@
|
| |
|
| |
from blockerbugs import db
|
| |
from blockerbugs import app
|
| |
- from blockerbugs.models.spin import Spin, SpinState, SpinType
|
| |
from blockerbugs.models.build import Build
|
| |
from blockerbugs.models.userinfo import UserInfo
|
| |
from testing.test_controllers import add_release, add_milestone, \
|
| |
- add_bug, add_spin, add_update
|
| |
+ add_bug, add_update
|
| |
from blockerbugs.controllers.api import errors
|
| |
|
| |
|
| |
@@ -41,19 +40,9 @@
|
| |
cls.update_testing2 = add_update(u'test-testing2.fc99', u'testing',
|
| |
[bug2],
|
| |
cls.release, [cls.milestone])
|
| |
- cls.spin2 = add_spin('test-spin2', SpinType.TC, [],
|
| |
- cls.milestone, state=SpinState.requested)
|
| |
-
|
| |
build = Build()
|
| |
build.koji_id = 33
|
| |
build.nvr = 'libofx-0.9.9-1.fc20'
|
| |
- cls.spin1 = add_spin('test-spin1', SpinType.TC,
|
| |
- [cls.update_pending_stable],
|
| |
- cls.milestone, state=SpinState.requested)
|
| |
- cls.spin1.builds = [build]
|
| |
- cls.spin1.date_requested = datetime(1990, 1, 1)
|
| |
- cls.spin1.succeeds = cls.spin2
|
| |
- cls.spin2.date_requested = datetime(2000, 1, 1)
|
| |
cls.api_user = UserInfo('api_user')
|
| |
passwd = cls.api_user.generate_api_key()
|
| |
cls.headers = {'X-Auth-User': 'api_user', 'X-Auth-Key': passwd}
|
| |
@@ -133,102 +122,6 @@
|
| |
update = data[0]
|
| |
assert update['title'] == u'test-testing2.fc99'
|
| |
|
| |
- def test_list_spins(self):
|
| |
- url = '/api/v0/milestones/99/final/spins'
|
| |
- resp = self.client.get(url)
|
| |
- assert resp.status_code == httplib.OK
|
| |
- data = json.loads(resp.data)
|
| |
- assert len(data) == 2
|
| |
- spin = Spin.query.filter_by(name='test-spin1').first()
|
| |
- resp_spin = data[1]
|
| |
- assert resp_spin['name'] == spin.name
|
| |
- assert resp_spin['id'] == spin.id
|
| |
- assert resp_spin['state'] == spin.state.value
|
| |
- assert resp_spin['url'] == spin.url
|
| |
- assert resp_spin['date_requested'] == datetime(1990, 1, 1).isoformat()
|
| |
- assert resp_spin['date_created'] is None
|
| |
- assert resp_spin['spin_type'] == spin.spin_type.value
|
| |
- assert len(resp_spin['updates']) == 1
|
| |
- assert {'title': u'test-pending-stable.fc99',
|
| |
- 'status': u'stable',
|
| |
- 'url': u'http://localhost/update'} in resp_spin['updates']
|
| |
- succeeded = Spin.query.filter_by(name='test-spin2').first()
|
| |
- assert resp_spin['succeeds']['name'] == succeeded.name
|
| |
- assert resp_spin['succeeds']['id'] == succeeded.id
|
| |
- assert {'version': 'final', 'release': 99} == resp_spin['milestone']
|
| |
-
|
| |
- def test_basic_create_spins(self):
|
| |
- url = '/api/v0/milestones/99/final/spins'
|
| |
- test_spin_data = {
|
| |
- 'name': 'create_spin_test1',
|
| |
- 'spin_type': 'TC',
|
| |
- 'updates': ['test-pending-stable.fc99'],
|
| |
- }
|
| |
- with patch('blockerbugs.models.spin.datetime') as mock_date:
|
| |
- mock_date.utcnow.return_value = datetime(1990, 1, 1)
|
| |
- mock_date.side_effect = lambda *args, **kw: datetime(*args, **kw)
|
| |
- resp = self.client.post(url,
|
| |
- data=json.dumps(test_spin_data),
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.CREATED
|
| |
- assert 'Location' in resp.headers
|
| |
- spin = Spin.query.filter_by(name='create_spin_test1').first()
|
| |
- assert spin.name == 'create_spin_test1'
|
| |
- assert spin.state == SpinState.requested
|
| |
- assert spin.url is None
|
| |
- assert spin.spin_type == SpinType.TC
|
| |
- assert len(spin.updates) == 1
|
| |
- assert spin.updates[0].title == 'test-pending-stable.fc99'
|
| |
- assert spin.succeeds is None
|
| |
- assert spin.milestone.version == 'final'
|
| |
- assert spin.milestone.release.number == 99
|
| |
- assert spin.date_requested == datetime(1990, 1, 1)
|
| |
-
|
| |
- def test_create_spin_fails_unknown_update_title(self):
|
| |
- url = '/api/v0/milestones/99/final/spins'
|
| |
- test_spin_data = {
|
| |
- 'name': 'create_spin_test1',
|
| |
- 'spin_type': 'TC',
|
| |
- 'updates': ['test-pending-stable.fc99', 'unknown'],
|
| |
- }
|
| |
- resp = self.client.post(url,
|
| |
- data=json.dumps(test_spin_data),
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.NOT_FOUND
|
| |
- error = json.loads(resp.data)['error']
|
| |
- assert error['code'] == errors.NoSuchObjectError.code
|
| |
- assert 'Update' in error['message']
|
| |
-
|
| |
- def test_invalid_spin_name(self):
|
| |
- url = '/api/v0/milestones/99/final/spins'
|
| |
- test_spin_data = {
|
| |
- 'name': 123,
|
| |
- 'spin_type': 'create_test1',
|
| |
- 'updates': ['test-pending-stable.fc99', 'unknown'],
|
| |
- 'succeeds': []
|
| |
- }
|
| |
- resp = self.client.post(url,
|
| |
- data=json.dumps(test_spin_data),
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.BAD_REQUEST
|
| |
- error = json.loads(resp.data)['error']
|
| |
- assert error['code'] == errors.ValidationError.code
|
| |
- assert 'name' in error['message']
|
| |
-
|
| |
- def test_malformed_spin_data_request(self):
|
| |
- url = '/api/v0/milestones/99/final/spins'
|
| |
- test_spin_data = "{'name'= 123}"
|
| |
- resp = self.client.post(url,
|
| |
- data=test_spin_data,
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.BAD_REQUEST
|
| |
- error = json.loads(resp.data)['error']
|
| |
- assert error['code'] == 1003
|
| |
-
|
| |
def test_bad_bugtype_list_bugs(self):
|
| |
url = '/api/v0/milestones/99/final/updates?bugtype=foo&'
|
| |
resp = self.client.get(url)
|
| |
@@ -237,59 +130,6 @@
|
| |
assert error['code'] == errors.InvalidArgumentError.code
|
| |
assert 'bugtype' in error['message']
|
| |
|
| |
- def test_get_specific_spin_info(self):
|
| |
- spin = Spin.query.filter_by(name='test-spin1').first()
|
| |
- url = '/api/v0/milestones/99/final/spins/%d' % (spin.id)
|
| |
- resp = self.client.get(url)
|
| |
- assert resp.status_code == httplib.OK
|
| |
- resp_spin = json.loads(resp.data)
|
| |
- assert resp_spin['name'] == spin.name
|
| |
- assert resp_spin['id'] == spin.id
|
| |
- assert resp_spin['state'] == spin.state.value
|
| |
- assert resp_spin['url'] == spin.url
|
| |
- assert resp_spin['date_requested'] == datetime(1990, 1, 1).isoformat()
|
| |
- assert resp_spin['date_created'] is None
|
| |
- assert resp_spin['spin_type'] == spin.spin_type.value
|
| |
- assert len(resp_spin['builds']) == 1
|
| |
- build = resp_spin['builds'][0]
|
| |
- assert build['id'] == spin.builds[0].koji_id
|
| |
- assert build['nvr'] == spin.builds[0].nvr
|
| |
- assert build['epoch'] == spin.builds[0].epoch
|
| |
-
|
| |
- def test_update_spin_created_date(self):
|
| |
- spin_id = Spin.query.filter_by(name='test-spin2').first().id
|
| |
- url = '/api/v0/milestones/99/final/spins/%d' % (spin_id)
|
| |
- date_created = datetime(1991, 1, 1)
|
| |
- update_data = {'date_created': date_created.isoformat(), }
|
| |
- resp = self.client.put(url, data=json.dumps(update_data),
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.OK
|
| |
- updated_spin = Spin.query.get(spin_id)
|
| |
- assert updated_spin.date_created == date_created
|
| |
-
|
| |
- def test_update_spin_invalid_created_date(self):
|
| |
- spin_id = Spin.query.filter_by(name='test-spin2').first().id
|
| |
- url = '/api/v0/milestones/99/final/spins/%d' % (spin_id)
|
| |
- date_created = 'invalid'
|
| |
- update_data = {'date_created': date_created, }
|
| |
- resp = self.client.put(url, data=json.dumps(update_data),
|
| |
- content_type='application/json',
|
| |
- headers=self.headers)
|
| |
- assert resp.status_code == httplib.BAD_REQUEST
|
| |
- error = json.loads(resp.data)['error']
|
| |
- assert error['code'] == errors.ValidationError.code
|
| |
-
|
| |
- def test_update_spin_auth_failed(self):
|
| |
- spin_id = Spin.query.filter_by(name='test-spin2').first().id
|
| |
- url = '/api/v0/milestones/99/final/spins/%d' % (spin_id)
|
| |
- update_data = {'date_created': 'foo', }
|
| |
- resp = self.client.put(url, data=json.dumps(update_data),
|
| |
- content_type='application/json')
|
| |
- assert resp.status_code == httplib.FORBIDDEN
|
| |
- error = json.loads(resp.data)['error']
|
| |
- assert error['code'] == errors.AuthFailedError.code
|
| |
-
|
| |
def test_get_current_milestone(self):
|
| |
url = '/api/v0/milestones/current'
|
| |
resp = self.client.get(url)
|
| |
This completely removes the "Spins" feature which has been unused and problematic when porting to Python 3.