~ubuntu-branches/ubuntu/raring/cinder/raring-updates

« back to all changes in this revision

Viewing changes to cinder/tests/test_volume_types_extra_specs.py

Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        self.context = context.get_admin_context()
31
31
        self.vol_type1 = dict(name="TEST: Regular volume test")
32
32
        self.vol_type1_specs = dict(vol_extra1="value1",
33
 
                                  vol_extra2="value2",
34
 
                                  vol_extra3=3)
 
33
                                    vol_extra2="value2",
 
34
                                    vol_extra3=3)
35
35
        self.vol_type1['extra_specs'] = self.vol_type1_specs
36
36
        ref = db.volume_type_create(self.context, self.vol_type1)
37
37
        self.volume_type1_id = ref.id
45
45
    def tearDown(self):
46
46
        # Remove the volume type from the database
47
47
        db.volume_type_destroy(context.get_admin_context(),
48
 
                               self.vol_type1['name'])
 
48
                               self.vol_type1['id'])
49
49
        db.volume_type_destroy(context.get_admin_context(),
50
 
                               self.vol_type2_noextra['name'])
 
50
                               self.vol_type2_noextra['id'])
51
51
        super(VolumeTypeExtraSpecsTestCase, self).tearDown()
52
52
 
53
53
    def test_volume_type_specs_get(self):
54
54
        expected_specs = self.vol_type1_specs.copy()
55
55
        actual_specs = db.volume_type_extra_specs_get(
56
 
                              context.get_admin_context(),
57
 
                              self.volume_type1_id)
 
56
            context.get_admin_context(),
 
57
            self.volume_type1_id)
58
58
        self.assertEquals(expected_specs, actual_specs)
59
59
 
60
60
    def test_volume_type_extra_specs_delete(self):
61
61
        expected_specs = self.vol_type1_specs.copy()
62
62
        del expected_specs['vol_extra2']
63
63
        db.volume_type_extra_specs_delete(context.get_admin_context(),
64
 
                                      self.volume_type1_id,
65
 
                                      'vol_extra2')
 
64
                                          self.volume_type1_id,
 
65
                                          'vol_extra2')
66
66
        actual_specs = db.volume_type_extra_specs_get(
67
 
                              context.get_admin_context(),
68
 
                              self.volume_type1_id)
 
67
            context.get_admin_context(),
 
68
            self.volume_type1_id)
69
69
        self.assertEquals(expected_specs, actual_specs)
70
70
 
71
71
    def test_volume_type_extra_specs_update(self):
72
72
        expected_specs = self.vol_type1_specs.copy()
73
73
        expected_specs['vol_extra3'] = "4"
74
74
        db.volume_type_extra_specs_update_or_create(
75
 
                              context.get_admin_context(),
76
 
                              self.volume_type1_id,
77
 
                              dict(vol_extra3=4))
 
75
            context.get_admin_context(),
 
76
            self.volume_type1_id,
 
77
            dict(vol_extra3=4))
78
78
        actual_specs = db.volume_type_extra_specs_get(
79
 
                              context.get_admin_context(),
80
 
                              self.volume_type1_id)
 
79
            context.get_admin_context(),
 
80
            self.volume_type1_id)
81
81
        self.assertEquals(expected_specs, actual_specs)
82
82
 
83
83
    def test_volume_type_extra_specs_create(self):
85
85
        expected_specs['vol_extra4'] = 'value4'
86
86
        expected_specs['vol_extra5'] = 'value5'
87
87
        db.volume_type_extra_specs_update_or_create(
88
 
                              context.get_admin_context(),
89
 
                              self.volume_type1_id,
90
 
                              dict(vol_extra4="value4",
91
 
                                   vol_extra5="value5"))
 
88
            context.get_admin_context(),
 
89
            self.volume_type1_id,
 
90
            dict(vol_extra4="value4",
 
91
                 vol_extra5="value5"))
92
92
        actual_specs = db.volume_type_extra_specs_get(
93
 
                              context.get_admin_context(),
94
 
                              self.volume_type1_id)
 
93
            context.get_admin_context(),
 
94
            self.volume_type1_id)
95
95
        self.assertEquals(expected_specs, actual_specs)
96
96
 
97
97
    def test_volume_type_get_with_extra_specs(self):
98
98
        volume_type = db.volume_type_get(
99
 
                            context.get_admin_context(),
100
 
                            self.volume_type1_id)
 
99
            context.get_admin_context(),
 
100
            self.volume_type1_id)
101
101
        self.assertEquals(volume_type['extra_specs'],
102
102
                          self.vol_type1_specs)
103
103
 
104
104
        volume_type = db.volume_type_get(
105
 
                            context.get_admin_context(),
106
 
                            self.vol_type2_id)
 
105
            context.get_admin_context(),
 
106
            self.vol_type2_id)
107
107
        self.assertEquals(volume_type['extra_specs'], {})
108
108
 
109
109
    def test_volume_type_get_by_name_with_extra_specs(self):
110
110
        volume_type = db.volume_type_get_by_name(
111
 
                            context.get_admin_context(),
112
 
                            self.vol_type1['name'])
 
111
            context.get_admin_context(),
 
112
            self.vol_type1['name'])
113
113
        self.assertEquals(volume_type['extra_specs'],
114
114
                          self.vol_type1_specs)
115
115
 
116
116
        volume_type = db.volume_type_get_by_name(
117
 
                            context.get_admin_context(),
118
 
                            self.vol_type2_noextra['name'])
 
117
            context.get_admin_context(),
 
118
            self.vol_type2_noextra['name'])
119
119
        self.assertEquals(volume_type['extra_specs'], {})
120
120
 
121
121
    def test_volume_type_get_all(self):