~vila/byov/trunk

« back to all changes in this revision

Viewing changes to byov/tests/test_nova.py

  • Committer: Vincent Ladeuil
  • Date: 2018-01-30 09:47:07 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20180130094707-yi9wfwnhlbg0jhia
Rename to byov.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This file is part of Online Services virtual machine tools.
 
1
# This file is part of Build Your Own Virtual machine.
2
2
#
 
3
# Copyright 2018 Vincent Ladeuil.
3
4
# Copyright 2016, 2017 Canonical Ltd.
4
5
#
5
6
# This program is free software: you can redistribute it and/or modify it under
19
20
import sys
20
21
import unittest
21
22
 
22
 
from olsconfig import options
23
 
from olstests import (
 
23
from byoc import options
 
24
from byot import (
24
25
    assertions,
25
26
    features,
26
27
    fixtures,
28
29
)
29
30
 
30
31
 
31
 
from olsvms import config
32
 
from olsvms.tests import (
 
32
from byov import config
 
33
from byov.tests import (
33
34
    features as vms_features,
34
35
    fixtures as vms_fixtures,
35
36
)
37
38
try:
38
39
    if sys.version_info < (3,):
39
40
        # novaclient doesn't support python3 (yet)
40
 
        from olsvms.vms import nova
 
41
        from byov.vms import nova
41
42
except ImportError:
42
43
    pass
43
44
 
46
47
 
47
48
 
48
49
@features.requires(vms_features.nova_creds)
49
 
class TestOlsImageName(unittest.TestCase):
 
50
class TestByovImageName(unittest.TestCase):
50
51
 
51
52
    def test_valid_britney_image(self):
52
53
        self.assertEqual(
53
 
            'ols/britney/precise-amd64.img',
54
 
            nova.ols_image_name('britney', 'precise', 'amd64'))
 
54
            'byov/britney/precise-amd64.img',
 
55
            nova.byov_image_name('britney', 'precise', 'amd64'))
55
56
 
56
57
    def test_valid_cloud_image(self):
57
58
        self.assertEqual(
58
 
            'ols/cloudimg/precise-amd64.img',
59
 
            nova.ols_image_name('cloudimg', 'precise', 'amd64'))
 
59
            'byov/cloudimg/precise-amd64.img',
 
60
            nova.byov_image_name('cloudimg', 'precise', 'amd64'))
60
61
 
61
62
    def test_invalid_image(self):
62
63
        with self.assertRaises(ValueError) as cm:
63
 
            nova.ols_image_name('I-dont-exist', 'precise', 'amd64')
 
64
            nova.byov_image_name('I-dont-exist', 'precise', 'amd64')
64
65
        self.assertEqual('Invalid image domain', str(cm.exception))
65
66
 
66
67
 
86
87
        vms_fixtures.override_logging(self, self.log_stream)
87
88
 
88
89
    def get_image_id(self, series, arch):
89
 
        return nova.ols_image_name('cloudimg', series, arch)
 
90
        return nova.byov_image_name('cloudimg', series, arch)
90
91
 
91
92
    def test_retry_is_called(self):
92
93
        self.retry_calls = []
183
184
        vms_fixtures.override_logging(self, self.log_stream)
184
185
 
185
186
    def get_image_id(self, series='precise', arch='amd64'):
186
 
        return nova.ols_image_name('cloudimg', series, arch)
 
187
        return nova.byov_image_name('cloudimg', series, arch)
187
188
 
188
189
    def test_create_no_image(self):
189
190
        tb = nova.NovaServer(self.conf)
274
275
        vms_fixtures.override_logging(self, self.log_stream)
275
276
 
276
277
    def get_image_id(self):
277
 
        return nova.ols_image_name('cloudimg', self.series, self.arch)
 
278
        return nova.byov_image_name('cloudimg', self.series, self.arch)
278
279
 
279
280
    def test_create_usable_testbed(self):
280
281
        self.conf.set('nova.image', self.get_image_id())