-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test, fix some problems, modify test_helpers.py for patch.
1. Add test cases for build images. 2. Fix problems according to review comments and tests. 3. Change class MockAPI in test_helpers.py to support PATCH method that not use '+='.
- Loading branch information
Showing
7 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"archives": [], | ||
"image_format": "docker", | ||
"image_id": "test_image_1", | ||
"md5": "11112222333344445555666677778899", | ||
"releases": [], | ||
"rpms": [], | ||
"url": "http://127.0.0.1:8000/rest_api/v1/build-images/1/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Image ID test_image_1 | ||
Image Format docker | ||
URL http://127.0.0.1:8000/rest_api/v1/build-images/1/ | ||
MD5 11112222333344445555666677778899 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
build-image-0 | ||
build-image-1 | ||
build-image-2 | ||
build-image-3 | ||
build-image-4 | ||
build-image-5 | ||
build-image-6 | ||
build-image-7 | ||
build-image-8 | ||
build-image-9 | ||
build-image-10 | ||
build-image-11 | ||
build-image-12 | ||
build-image-13 | ||
build-image-14 | ||
build-image-15 | ||
build-image-16 | ||
build-image-17 | ||
build-image-18 | ||
build-image-19 | ||
build-image-20 | ||
build-image-21 | ||
build-image-22 | ||
build-image-23 | ||
build-image-24 | ||
build-image-25 | ||
build-image-26 | ||
build-image-27 | ||
build-image-28 | ||
build-image-29 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
from pdc_client.test_helpers import CLITestCase | ||
from pdc_client.runner import Runner | ||
|
||
|
||
class BuildImageTestCase(CLITestCase): | ||
def setUp(self): | ||
self.runner = Runner() | ||
self.runner.setup() | ||
|
||
def _setup_list_1(self, api): | ||
api.add_endpoint('build-images', 'GET', [ | ||
{'image_id': 'build-image-{}'.format(x), | ||
'md5': '111122223333444455556666777788{:02}'.format(x)} | ||
for x in range(30) | ||
]) | ||
|
||
def _setup_detail(self, api): | ||
obj = {'image_id': 'test_image_1', | ||
'url': 'http://127.0.0.1:8000/rest_api/v1/build-images/1/', | ||
'image_format': 'docker', | ||
'md5': '11112222333344445555666677778899', | ||
'rpms': [], | ||
'archives': [], | ||
'releases': []} | ||
api.add_endpoint('build-images/1', 'PATCH', obj) | ||
api.add_endpoint('build-images/1', 'GET', obj) | ||
api.add_endpoint('build-images', 'POST', obj) | ||
|
||
def _setup_list_2(self, api): | ||
filter_result = { | ||
"count": 1, | ||
"next": None, | ||
"previous": None, | ||
"results": [ | ||
{ | ||
"archives": [], | ||
"image_format": "docker", | ||
"image_id": "test_image_1", | ||
"md5": "11112222333344445555666677778899", | ||
"releases": [], | ||
"rpms": [], | ||
"url": "http://127.0.0.1:8000/rest_api/v1/build-images/1/" | ||
} | ||
] | ||
} | ||
|
||
api.add_endpoint('build-images', 'GET', filter_result) | ||
|
||
def test_list(self, api): | ||
self._setup_list_1(api) | ||
with self.expect_output('list_multi_page.txt'): | ||
self.runner.run(['build-image-list']) | ||
self.assertEqual(api.calls['build-images'], | ||
[('GET', {'page': 1}), | ||
('GET', {'page': 2})]) | ||
|
||
def test_info(self, api): | ||
self._setup_detail(api) | ||
self._setup_list_2(api) | ||
with self.expect_output('detail.json', parse_json=True): | ||
self.runner.run(['--json', 'build-image-info', 'test_image_1']) | ||
self.assertEqual(api.calls['build-images'], [('GET', {'image_id': 'test_image_1'})]) | ||
|
||
def test_create(self, api): | ||
self._setup_detail(api) | ||
self._setup_list_2(api) | ||
with self.expect_output('detail.txt'): | ||
self.runner.run(['build-image-create', | ||
'--image-id', 'test_image_1', | ||
'--image-format', 'docker', | ||
'--md5', '11112222333344445555666677778899']) | ||
self.assertEqual(api.calls['build-images'], [('POST', {'image_format': 'docker', | ||
'image_id': 'test_image_1', | ||
'md5': '11112222333344445555666677778899'}), | ||
('GET', {'image_id': 'test_image_1'})]) | ||
|
||
def test_update(self, api): | ||
self._setup_detail(api) | ||
self._setup_list_2(api) | ||
with self.expect_output('detail.txt'): | ||
self.runner.run(['build-image-update', 'test_image_1', | ||
'--image-format', 'docker', | ||
'--md5', '11112222333344445555666677778899']) |