Skip to content
Permalink
Browse files
Add image unittests
  • Loading branch information
brogand93 committed Jun 1, 2014
1 parent 4c8c45c commit 4f6c65098ae3465331197c173b4924f48e68f982
Showing 4 changed files with 48 additions and 14 deletions.
@@ -24,7 +24,7 @@
"sshkeyenabled": false,
"isextractable": false,
"account": "system",
"name": "CentOS 5.3(64-bit) no GUI (Simulator)",
"name": "imagename",
"created": "2014-02-15T02:50:13+0000",
"hypervisor": "Simulator",
"ispublic": true,
@@ -0,0 +1,47 @@
#!/usr/bin/env python
# encoding: utf-8

import mock

from gstack.helpers import read_file
from . import GStackAppTestCase

class ZonesTestCase(GStackAppTestCase):

def test_list_images(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_describe_images.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/global/images', headers=headers)

self.assert_ok(response)

def test_get_image(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/valid_describe_images.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/global/images/imagename', headers=headers)

self.assert_ok(response)

def test_get_zone_not_found(self):

get = mock.Mock()
get.return_value.text = read_file('tests/data/empty_describe_images.json')
get.return_value.status_code = 200

with mock.patch('requests.get', get):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/global/images/imagename', headers=headers)

self.assert_not_found(response)
assert 'The resource \'/compute/v1/projects/exampleproject/global/images/imagename\' was not found' \
in response.data

This file was deleted.

@@ -1,8 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8

from unittest import TestCase

import mock

from gstack.helpers import read_file
@@ -44,8 +42,6 @@ def test_get_zone_not_found(self):
headers = {'authorization': 'Bearer ' + str(GStackAppTestCase.access_token)}
response = self.get('/compute/v1/projects/exampleproject/zones/zonename', headers=headers)

print response.data

self.assert_not_found(response)
assert 'The resource \'/compute/v1/projects/exampleproject/zones/zonename\' was not found' \
in response.data

0 comments on commit 4f6c650

Please sign in to comment.