/usr/lib/python2.7/dist-packages/magnum/tests/unit/objects/test_fields.py is in python-magnum 3.1.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | # Copyright 2015 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects.tests import test_fields
from magnum.objects import fields
class TestClusterStatus(test_fields.TestField):
def setUp(self):
super(TestClusterStatus, self).setUp()
self.field = fields.ClusterStatusField()
self.coerce_good_values = [('CREATE_IN_PROGRESS',
'CREATE_IN_PROGRESS'),
('CREATE_FAILED', 'CREATE_FAILED'),
('CREATE_COMPLETE', 'CREATE_COMPLETE'),
('UPDATE_IN_PROGRESS',
'UPDATE_IN_PROGRESS'),
('UPDATE_FAILED', 'UPDATE_FAILED'),
('UPDATE_COMPLETE', 'UPDATE_COMPLETE'),
('DELETE_IN_PROGRESS',
'DELETE_IN_PROGRESS'),
('DELETE_FAILED', 'DELETE_FAILED'),
('RESUME_COMPLETE', 'RESUME_COMPLETE'),
('RESTORE_COMPLETE', 'RESTORE_COMPLETE'),
('ROLLBACK_COMPLETE', 'ROLLBACK_COMPLETE'),
('SNAPSHOT_COMPLETE', 'SNAPSHOT_COMPLETE'),
('CHECK_COMPLETE', 'CHECK_COMPLETE'),
('ADOPT_COMPLETE', 'ADOPT_COMPLETE')]
self.coerce_bad_values = ['DELETE_STOPPED']
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]
def test_stringify(self):
self.assertEqual("'UPDATE_FAILED'",
self.field.stringify('UPDATE_FAILED'))
def test_stringify_invalid(self):
self.assertRaises(ValueError, self.field.stringify, 'DELETE_STOPPED')
class TestContainerStatus(test_fields.TestField):
def setUp(self):
super(TestContainerStatus, self).setUp()
self.field = fields.ContainerStatusField()
self.coerce_good_values = [('Error', 'Error'), ('Running', 'Running'),
('Stopped', 'Stopped'),
('Paused', 'Paused'),
('Unknown', 'Unknown'), ]
self.coerce_bad_values = ['DELETED']
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]
def test_stringify(self):
self.assertEqual("'Stopped'",
self.field.stringify('Stopped'))
def test_stringify_invalid(self):
self.assertRaises(ValueError, self.field.stringify, 'DELETED')
class TestClusterType(test_fields.TestField):
def setUp(self):
super(TestClusterType, self).setUp()
self.field = fields.ClusterTypeField()
self.coerce_good_values = [('kubernetes', 'kubernetes'),
('swarm', 'swarm'),
('mesos', 'mesos'), ]
self.coerce_bad_values = ['invalid']
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]
def test_stringify(self):
self.assertEqual("'kubernetes'",
self.field.stringify('kubernetes'))
def test_stringify_invalid(self):
self.assertRaises(ValueError, self.field.stringify, 'invalid')
class TestMagnumServiceBinary(test_fields.TestField):
def setUp(self):
super(TestMagnumServiceBinary, self).setUp()
self.field = fields.MagnumServiceBinaryField()
self.coerce_good_values = [('magnum-conductor', 'magnum-conductor')]
self.coerce_bad_values = ['invalid']
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]
def test_stringify(self):
self.assertEqual("'magnum-conductor'",
self.field.stringify('magnum-conductor'))
def test_stringify_invalid(self):
self.assertRaises(ValueError, self.field.stringify, 'invalid')
|