Add unit test for translate with no translate value

This happens in validate values, just add unit test to make sure we
always raise error when it happens.
Related-Bug: #1685808

Change-Id: Ifa9f2920f6ae55d0a5f09e4d1a5bed6c93d47b6f
This commit is contained in:
ricolin 2017-04-27 13:58:05 +08:00 committed by Rico Lin
parent 76eafe84de
commit 2b980b3243
1 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from oslo_serialization import jsonutils
import six
@ -23,6 +24,7 @@ from heat.engine import plugin_manager
from heat.engine import properties
from heat.engine import resources
from heat.engine import support
from heat.engine import translation
from heat.tests import common
@ -1086,6 +1088,14 @@ class PropertiesTest(common.HeatTestCase):
def test_missing_required(self):
self.assertRaises(ValueError, self.props.get, 'required_int')
@mock.patch.object(translation.Translation, 'has_translation')
@mock.patch.object(translation.Translation, 'translate')
def test_required_with_translate_no_value(self, m_t, m_ht):
m_t.return_value = None
m_ht.return_value = True
self.assertRaises(ValueError, self.props.get, 'required_int')
def test_integer_bad(self):
self.assertRaises(ValueError, self.props.get, 'bad_int')