~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/tests/test_states.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-03-30 11:14:57 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20150330111457-kr4ju3guf22m4vbz
Tags: 2015.1~b3-0ubuntu1
* New upstream release.
  + d/control: 
    - Align with upstream dependencies.
    - Add dh-python to build-dependencies.
    - Add psmisc as a dependency. (LP: #1358820)
  + d/p/fix-requirements.patch: Rediffed.
  + d/ironic-conductor.init.in: Fixed typos in LSB headers,
    thanks to JJ Asghar. (LP: #1429962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
#    Copyright (C) 2015 Intel Corporation. All Rights Reserved.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
from ironic.common import states
 
18
from ironic.tests import base
 
19
 
 
20
 
 
21
class StatesTest(base.TestCase):
 
22
 
 
23
    def test_state_values_length(self):
 
24
        """test_state_values_length
 
25
 
 
26
        State values can be a maximum of 15 characters because they are stored
 
27
        in the database and the size of the database entry is 15 characters.
 
28
        This is specified in db/sqlalchemy/models.py
 
29
 
 
30
    """
 
31
        for key, value in states.__dict__.iteritems():
 
32
            # Assumption: A state variable name is all UPPERCASE and contents
 
33
            # are a string.
 
34
            if key.upper() == key and isinstance(value, basestring):
 
35
                self.assertTrue(
 
36
                    (len(value) <= 15),
 
37
                    "Value for state: {} is greater than 15 characters".format(
 
38
                        key))