/usr/lib/python2.7/dist-packages/toscaparser/tests/test_toscatplvalidation.py is in python-tosca-parser 0.1.0-3.
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | # 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.
import os
import six
from toscaparser.common import exception
from toscaparser.nodetemplate import NodeTemplate
from toscaparser.parameters import Input
from toscaparser.parameters import Output
from toscaparser.relationship_template import RelationshipTemplate
from toscaparser.tests.base import TestCase
from toscaparser.tosca_template import ToscaTemplate
import toscaparser.utils.yamlparser
class ToscaTemplateValidationTest(TestCase):
def test_well_defined_template(self):
tpl_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/tosca_single_instance_wordpress.yaml")
self.assertIsNotNone(ToscaTemplate(tpl_path))
def test_first_level_sections(self):
tpl_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/test_tosca_top_level_error1.yaml")
err = self.assertRaises(exception.MissingRequiredFieldError,
ToscaTemplate, tpl_path)
self.assertEqual('Template is missing required field: '
'"tosca_definitions_version".', err.__str__())
tpl_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/test_tosca_top_level_error2.yaml")
err = self.assertRaises(exception.UnknownFieldError,
ToscaTemplate, tpl_path)
self.assertEqual('Template contain(s) unknown field: '
'"node_template", refer to the definition '
'to verify valid values.', err.__str__())
def test_inputs(self):
tpl_snippet = '''
inputs:
cpus:
type: integer
description: Number of CPUs for the server.
constraint:
- valid_values: [ 1, 2, 4, 8 ]
'''
inputs = (toscaparser.utils.yamlparser.
simple_parse(tpl_snippet)['inputs'])
name, attrs = list(inputs.items())[0]
input = Input(name, attrs)
try:
input.validate()
except Exception as err:
self.assertTrue(isinstance(err, exception.UnknownFieldError))
self.assertEqual('Input cpus contain(s) unknown field: '
'"constraint", refer to the definition to '
'verify valid values.', err.__str__())
def test_outputs(self):
tpl_snippet = '''
outputs:
server_address:
description: IP address of server instance.
values: { get_property: [server, private_address] }
'''
outputs = (toscaparser.utils.yamlparser.
simple_parse(tpl_snippet)['outputs'])
name, attrs = list(outputs.items())[0]
output = Output(name, attrs)
try:
output.validate()
except Exception as err:
self.assertTrue(
isinstance(err, exception.MissingRequiredFieldError))
self.assertEqual('Output server_address is missing required '
'field: "value".', err.__str__())
tpl_snippet = '''
outputs:
server_address:
descriptions: IP address of server instance.
value: { get_property: [server, private_address] }
'''
outputs = (toscaparser.utils.yamlparser.
simple_parse(tpl_snippet)['outputs'])
name, attrs = list(outputs.items())[0]
output = Output(name, attrs)
try:
output.validate()
except Exception as err:
self.assertTrue(isinstance(err, exception.UnknownFieldError))
self.assertEqual('Output server_address contain(s) unknown '
'field: "descriptions", refer to the definition '
'to verify valid values.',
err.__str__())
def _custom_types(self):
custom_types = {}
def_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/custom_types/wordpress.yaml")
custom_type = toscaparser.utils.yamlparser.load_yaml(def_file)
node_types = custom_type['node_types']
for name in node_types:
defintion = node_types[name]
custom_types[name] = defintion
return custom_types
def _single_node_template_content_test(self, tpl_snippet, expectederror,
expectedmessage):
nodetemplates = (toscaparser.utils.yamlparser.
simple_ordered_parse(tpl_snippet))['node_templates']
name = list(nodetemplates.keys())[0]
try:
nodetemplate = NodeTemplate(name, nodetemplates,
self._custom_types())
nodetemplate.validate()
nodetemplate.requirements
nodetemplate.get_capabilities_objects()
nodetemplate.get_properties_objects()
nodetemplate.interfaces
except Exception as err:
self.assertTrue(isinstance(err, expectederror))
self.assertEqual(expectedmessage, err.__str__())
def test_node_templates(self):
tpl_snippet = '''
node_templates:
server:
capabilities:
host:
properties:
disk_size: 10
num_cpus: 4
mem_size: 4096
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
'''
expectedmessage = ('Template server is missing '
'required field: "type".')
self._single_node_template_content_test(
tpl_snippet,
exception.MissingRequiredFieldError,
expectedmessage)
def test_node_template_with_wrong_properties_keyname(self):
"""Node template keyname 'properties' given as 'propertiessss'."""
tpl_snippet = '''
node_templates:
mysql_dbms:
type: tosca.nodes.DBMS
propertiessss:
root_password: aaa
port: 3376
'''
expectedmessage = ('Node template mysql_dbms '
'contain(s) unknown field: "propertiessss", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_with_wrong_requirements_keyname(self):
"""Node template keyname 'requirements' given as 'requirement'."""
tpl_snippet = '''
node_templates:
mysql_dbms:
type: tosca.nodes.DBMS
properties:
root_password: aaa
port: 3376
requirement:
- host: server
'''
expectedmessage = ('Node template mysql_dbms '
'contain(s) unknown field: "requirement", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_with_wrong_interfaces_keyname(self):
"""Node template keyname 'interfaces' given as 'interfac'."""
tpl_snippet = '''
node_templates:
mysql_dbms:
type: tosca.nodes.DBMS
properties:
root_password: aaa
port: 3376
requirements:
- host: server
interfac:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Node template mysql_dbms '
'contain(s) unknown field: "interfac", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_with_wrong_capabilities_keyname(self):
"""Node template keyname 'capabilities' given as 'capabilitiis'."""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilitiis:
database_endpoint:
properties:
port: { get_input: db_port }
'''
expectedmessage = ('Node template mysql_database '
'contain(s) unknown field: "capabilitiis", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_with_wrong_artifacts_keyname(self):
"""Node template keyname 'artifacts' given as 'artifactsss'."""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
artifactsss:
db_content:
implementation: files/my_db_content.txt
type: tosca.artifacts.File
'''
expectedmessage = ('Node template mysql_database '
'contain(s) unknown field: "artifactsss", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_with_multiple_wrong_keynames(self):
"""Node templates given with multiple wrong keynames."""
tpl_snippet = '''
node_templates:
mysql_dbms:
type: tosca.nodes.DBMS
propertieees:
root_password: aaa
port: 3376
requirements:
- host: server
interfacs:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Node template mysql_dbms '
'contain(s) unknown field: "propertieees", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
properties:
name: { get_input: db_name }
user: { get_input: db_user }
password: { get_input: db_pwd }
capabilitiiiies:
database_endpoint:
properties:
port: { get_input: db_port }
requirementsss:
- host:
node: mysql_dbms
interfac:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Node template mysql_database '
'contain(s) unknown field: "capabilitiiiies", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_type(self):
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Databases
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilities:
database_endpoint:
properties:
port: { get_input: db_port }
requirements:
- host: mysql_dbms
interfaces:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Type "tosca.nodes.Databases" is not '
'a valid type.')
self._single_node_template_content_test(tpl_snippet,
exception.InvalidTypeError,
expectedmessage)
def test_node_template_requirements(self):
tpl_snippet = '''
node_templates:
webserver:
type: tosca.nodes.WebServer
requirements:
host: server
interfaces:
Standard:
create: webserver_install.sh
start: d.sh
'''
expectedmessage = ('Requirements of template webserver '
'must be of type: "list".')
self._single_node_template_content_test(tpl_snippet,
exception.TypeMismatchError,
expectedmessage)
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilities:
database_endpoint:
properties:
port: { get_input: db_port }
requirements:
- host: mysql_dbms
- database_endpoint: mysql_database
interfaces:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "database_endpoint", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_requirements_with_wrong_node_keyname(self):
"""Node template requirements keyname 'node' given as 'nodes'."""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
requirements:
- host:
nodes: mysql_dbms
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "nodes", refer to the '
'definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_requirements_with_wrong_capability_keyname(self):
"""Incorrect node template requirements keyname
Node template requirements keyname 'capability' given as
'capabilityy'.
"""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
requirements:
- host:
node: mysql_dbms
- log_endpoint:
node: logstash
capabilityy: log_endpoint
relationship:
type: tosca.relationships.ConnectsTo
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "capabilityy", refer to '
'the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_requirements_with_wrong_relationship_keyname(self):
"""Incorrect node template requirements keyname
Node template requirements keyname 'relationship' given as
'relationshipppp'.
"""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
requirements:
- host:
node: mysql_dbms
- log_endpoint:
node: logstash
capability: log_endpoint
relationshipppp:
type: tosca.relationships.ConnectsTo
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "relationshipppp", refer'
' to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_requirements_with_multiple_wrong_keynames(self):
"""Node templates given with multiple wrong requirements keynames."""
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
requirements:
- host:
node: mysql_dbms
- log_endpoint:
nod: logstash
capabilit: log_endpoint
relationshipppp:
type: tosca.relationships.ConnectsTo
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "nod", refer'
' to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
requirements:
- host:
node: mysql_dbms
- log_endpoint:
node: logstash
capabilit: log_endpoint
relationshipppp:
type: tosca.relationships.ConnectsTo
'''
expectedmessage = ('Requirements of template mysql_database '
'contain(s) unknown field: "capabilit", refer'
' to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_capabilities(self):
tpl_snippet = '''
node_templates:
mysql_database:
type: tosca.nodes.Database
properties:
db_name: { get_input: db_name }
db_user: { get_input: db_user }
db_password: { get_input: db_pwd }
capabilities:
http_endpoint:
properties:
port: { get_input: db_port }
requirements:
- host: mysql_dbms
interfaces:
Standard:
configure: mysql_database_configure.sh
'''
expectedmessage = ('Capabilities of template mysql_database '
'contain(s) unknown field: "http_endpoint", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_properties(self):
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.Compute
properties:
os_image: F18_x86_64
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
'''
expectedmessage = ('Properties of template server contain(s) '
'unknown field: "os_image", refer to the '
'definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_node_template_interfaces(self):
tpl_snippet = '''
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
Standards:
create: wordpress_install.sh
configure:
implementation: wordpress_configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, \
db_password ] }
wp_db_port: { get_property: [ SELF, \
database_endpoint, port ] }
'''
expectedmessage = ('Interfaces of template wordpress '
'contain(s) unknown field: '
'"Standards", '
'refer to the definition to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
tpl_snippet = '''
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
Standard:
create: wordpress_install.sh
config:
implementation: wordpress_configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, \
db_password ] }
wp_db_port: { get_property: [ SELF, \
database_endpoint, port ] }
'''
expectedmessage = ('Interfaces of template wordpress contain(s) '
'unknown field: "config", refer to the definition'
' to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
tpl_snippet = '''
node_templates:
wordpress:
type: tosca.nodes.WebApplication.WordPress
requirements:
- host: webserver
- database_endpoint: mysql_database
interfaces:
Standard:
create: wordpress_install.sh
configure:
implementation: wordpress_configure.sh
inputs:
wp_db_name: { get_property: [ mysql_database, db_name ] }
wp_db_user: { get_property: [ mysql_database, db_user ] }
wp_db_password: { get_property: [ mysql_database, \
db_password ] }
wp_db_port: { get_ref_property: [ database_endpoint, \
database_endpoint, port ] }
'''
expectedmessage = ('Interfaces of template wordpress contain(s) '
'unknown field: "inputs", refer to the definition'
' to verify valid values.')
self._single_node_template_content_test(tpl_snippet,
exception.UnknownFieldError,
expectedmessage)
def test_relationship_template_properties(self):
tpl_snippet = '''
relationship_templates:
storage_attachto:
type: AttachesTo
properties:
device: test_device
'''
expectedmessage = ('Properties of template '
'storage_attachto is missing required field: '
'"[\'location\']".')
self._single_rel_template_content_test(
tpl_snippet,
exception.MissingRequiredFieldError,
expectedmessage)
def _single_rel_template_content_test(self, tpl_snippet, expectederror,
expectedmessage):
rel_template = (toscaparser.utils.yamlparser.
simple_parse(tpl_snippet))['relationship_templates']
name = list(rel_template.keys())[0]
rel_template = RelationshipTemplate(rel_template[name], name)
err = self.assertRaises(expectederror, rel_template.validate)
self.assertEqual(expectedmessage, six.text_type(err))
def test_invalid_template_version(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/test_invalid_template_version.yaml")
err = self.assertRaises(exception.InvalidTemplateVersion,
ToscaTemplate, tosca_tpl)
valid_versions = ', '.join(ToscaTemplate.VALID_TEMPLATE_VERSIONS)
ex_err_msg = ('The template version "tosca_xyz" is invalid. '
'The valid versions are: "%s"' % valid_versions)
self.assertEqual(six.text_type(err), ex_err_msg)
def test_node_template_capabilities_properties(self):
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
scalable:
properties:
min_instances: 1
default_instances: 5
'''
expectedmessage = ('Properties of template server is missing '
'required field: '
'"[\'max_instances\']".')
self._single_node_template_content_test(
tpl_snippet,
exception.MissingRequiredFieldError,
expectedmessage)
# validatating capability property values
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.WebServer
capabilities:
data_endpoint:
properties:
initiator: test
'''
expectedmessage = ('initiator: test is not an valid value '
'"[source, target, peer]".')
self._single_node_template_content_test(
tpl_snippet,
exception.ValidationError,
expectedmessage)
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.Compute
capabilities:
host:
properties:
disk_size: 10 GB
num_cpus: { get_input: cpus }
mem_size: 4096 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: Fedora
version: 18.0
scalable:
properties:
min_instances: 1
max_instances: 3
default_instances: 5
'''
expectedmessage = ('Properties of template server : '
'default_instances value is not between'
' min_instances and max_instances')
self._single_node_template_content_test(
tpl_snippet,
exception.ValidationError,
expectedmessage)
def test_node_template_objectstorage_without_required_property(self):
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.ObjectStorage
properties:
maxsize: 1 GB
'''
expectedmessage = ('Properties of template server is missing '
'required field: '
'"[\'name\']".')
self._single_node_template_content_test(
tpl_snippet,
exception.MissingRequiredFieldError,
expectedmessage)
def test_node_template_objectstorage_with_invalid_scalar_unit(self):
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.ObjectStorage
properties:
name: test
maxsize: -1
'''
expectedmessage = ('"-1" is not a valid scalar-unit')
self._single_node_template_content_test(
tpl_snippet,
ValueError,
expectedmessage)
def test_node_template_objectstorage_with_invalid_scalar_type(self):
tpl_snippet = '''
node_templates:
server:
type: tosca.nodes.ObjectStorage
properties:
name: test
maxsize: 1 XB
'''
expectedmessage = ('"1 XB" is not a valid scalar-unit')
self._single_node_template_content_test(
tpl_snippet,
ValueError,
expectedmessage)
|