~allanlesage/uci-engine/coverage-extractor-plus-nfss-juju-deployment

« back to all changes in this revision

Viewing changes to ci-utils/ci_utils/tests/test_image_store.py

  • Committer: Allan LeSage
  • Date: 2014-10-18 01:02:13 UTC
  • mfrom: (817.1.42 uci-engine)
  • Revision ID: allan.lesage@canonical.com-20141018010213-um3fn28281v2204v
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# You should have received a copy of the GNU Affero General Public License
15
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
 
from ci_utils.image_store import ImageStore, ImageStoreException
 
17
from ci_utils import image_store
18
18
from keystoneclient.exceptions import AuthorizationFailure
19
19
import unittest
20
20
import mock
31
31
            'auth_password': 'bad data',
32
32
            'auth_tenant_name': 'bad data'
33
33
        }
34
 
        with self.assertRaises(ImageStoreException):
35
 
            ImageStore(auth_data)
 
34
        with self.assertRaises(image_store.ImageStoreException):
 
35
            image_store.ImageStore(auth_data)
36
36
 
37
37
    def test_missing_auth(self):
38
 
        with self.assertRaises(ImageStoreException):
39
 
            ImageStore({})
 
38
        with self.assertRaises(image_store.ImageStoreException):
 
39
            image_store.ImageStore({})
40
40
 
41
41
    def test_bad_server(self):
42
42
        auth_data = {
45
45
            'auth_password': 'bad data',
46
46
            'auth_tenant_name': 'bad data'
47
47
        }
48
 
        with self.assertRaises(ImageStoreException):
49
 
            ImageStore(auth_data)
 
48
        with self.assertRaises(image_store.ImageStoreException):
 
49
            image_store.ImageStore(auth_data)
 
50
 
 
51
 
 
52
class TestUciImageName(unittest.TestCase):
 
53
 
 
54
    def test_valid_britney_image(self):
 
55
        self.assertEqual(
 
56
            'uci/britney/precise-amd64.img',
 
57
            image_store.uci_image_name('britney', 'precise', 'amd64'))
 
58
 
 
59
    def test_valid_cloud_image(self):
 
60
        self.assertEqual(
 
61
            'uci/cloudimg/precise-amd64.img',
 
62
            image_store.uci_image_name('cloudimg', 'precise', 'amd64'))
 
63
 
 
64
    def test_invalid_image(self):
 
65
        with self.assertRaises(ValueError) as cm:
 
66
            image_store.uci_image_name('I-dont-exist', 'precise', 'amd64')
 
67
        self.assertEqual('Invalid image domain', unicode(cm.exception))
 
68
 
50
69
 
51
70
if __name__ == "__main__":
52
71
    unittest.main()