Browse Source

Fix UTs due to change in Heat stack create

Adapting UTs per changes in Heat commits:
a5297fec8a
ed52c86549
10a00d3ee4

Change-Id: If983dd6dc49d3fa72e2504e225411a1d13230145
Closes-bug: 1476074
tags/2015.1.0b4
Sumit Naiksatam 3 years ago
parent
commit
61a2c9cfb0
2 changed files with 175 additions and 140 deletions
  1. 146
    120
      gbpautomation/heat/tests/test_grouppolicy.py
  2. 29
    20
      gbpautomation/heat/tests/test_servicechain.py

+ 146
- 120
gbpautomation/heat/tests/test_grouppolicy.py View File

@@ -319,10 +319,10 @@ class PolicyTargetTest(HeatTestCase):
319 319
         }).AndReturn({'policy_target': {'id': '5678'}})
320 320
 
321 321
         snippet = template_format.parse(policy_target_template)
322
-        stack = utils.parse_stack(snippet)
323
-        resource_defns = stack.t.resource_definitions(stack)
322
+        self.stack = utils.parse_stack(snippet)
323
+        resource_defns = self.stack.t.resource_definitions(self.stack)
324 324
         return grouppolicy.PolicyTarget(
325
-            'policy_target', resource_defns['policy_target'], stack)
325
+            'policy_target', resource_defns['policy_target'], self.stack)
326 326
 
327 327
     def test_create(self):
328 328
         rsrc = self.create_policy_target()
@@ -342,16 +342,17 @@ class PolicyTargetTest(HeatTestCase):
342 342
         self.m.ReplayAll()
343 343
 
344 344
         snippet = template_format.parse(policy_target_template)
345
-        stack = utils.parse_stack(snippet)
346
-        resource_defns = stack.t.resource_definitions(stack)
345
+        self.stack = utils.parse_stack(snippet)
346
+        resource_defns = self.stack.t.resource_definitions(self.stack)
347 347
         rsrc = grouppolicy.PolicyTarget(
348
-            'policy_target', resource_defns['policy_target'], stack)
348
+            'policy_target', resource_defns['policy_target'], self.stack)
349 349
 
350 350
         error = self.assertRaises(exception.ResourceFailure,
351 351
                                   scheduler.TaskRunner(rsrc.create))
352 352
         self.assertEqual(
353
-            'NeutronClientException: An unknown exception occurred.',
354
-            str(error))
353
+            'NeutronClientException: resources.policy_target: '
354
+            'An unknown exception occurred.',
355
+            six.text_type(error))
355 356
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
356 357
         self.m.VerifyAll()
357 358
 
@@ -388,7 +389,8 @@ class PolicyTargetTest(HeatTestCase):
388 389
         error = self.assertRaises(exception.ResourceFailure,
389 390
                                   scheduler.TaskRunner(rsrc.delete))
390 391
         self.assertEqual(
391
-            'NeutronClientException: An unknown exception occurred.',
392
+            'NeutronClientException: resources.policy_target: '
393
+            'An unknown exception occurred.',
392 394
             six.text_type(error))
393 395
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
394 396
         self.m.VerifyAll()
@@ -411,7 +413,7 @@ class PolicyTargetTest(HeatTestCase):
411 413
                                   rsrc.FnGetAtt, 'l2_policy_id')
412 414
         self.assertEqual(
413 415
             'The Referenced Attribute (policy_target l2_policy_id) is '
414
-            'incorrect.', str(error))
416
+            'incorrect.', six.text_type(error))
415 417
         self.m.VerifyAll()
416 418
 
417 419
     def test_update(self):
@@ -459,11 +461,11 @@ class PolicyTargetGroupTest(HeatTestCase):
459 461
         }).AndReturn({'policy_target_group': {'id': '5678'}})
460 462
 
461 463
         snippet = template_format.parse(policy_target_group_template)
462
-        stack = utils.parse_stack(snippet)
463
-        resource_defns = stack.t.resource_definitions(stack)
464
+        self.stack = utils.parse_stack(snippet)
465
+        resource_defns = self.stack.t.resource_definitions(self.stack)
464 466
         return grouppolicy.PolicyTargetGroup(
465 467
             'policy_target_group', resource_defns['policy_target_group'],
466
-            stack)
468
+            self.stack)
467 469
 
468 470
     def test_create(self):
469 471
         rsrc = self.create_policy_target_group()
@@ -492,17 +494,18 @@ class PolicyTargetGroupTest(HeatTestCase):
492 494
         self.m.ReplayAll()
493 495
 
494 496
         snippet = template_format.parse(policy_target_group_template)
495
-        stack = utils.parse_stack(snippet)
496
-        resource_defns = stack.t.resource_definitions(stack)
497
+        self.stack = utils.parse_stack(snippet)
498
+        resource_defns = self.stack.t.resource_definitions(self.stack)
497 499
         rsrc = grouppolicy.PolicyTargetGroup(
498 500
             'policy_target_group', resource_defns['policy_target_group'],
499
-            stack)
501
+            self.stack)
500 502
 
501 503
         error = self.assertRaises(exception.ResourceFailure,
502 504
                                   scheduler.TaskRunner(rsrc.create))
503 505
         self.assertEqual(
504
-            'NeutronClientException: An unknown exception occurred.',
505
-            str(error))
506
+            'NeutronClientException: resources.policy_target_group: '
507
+            'An unknown exception occurred.',
508
+            six.text_type(error))
506 509
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
507 510
         self.m.VerifyAll()
508 511
 
@@ -539,8 +542,9 @@ class PolicyTargetGroupTest(HeatTestCase):
539 542
         error = self.assertRaises(exception.ResourceFailure,
540 543
                                   scheduler.TaskRunner(rsrc.delete))
541 544
         self.assertEqual(
542
-            'NeutronClientException: An unknown exception occurred.',
543
-            str(error))
545
+            'NeutronClientException: resources.policy_target_group: '
546
+            'An unknown exception occurred.',
547
+            six.text_type(error))
544 548
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
545 549
         self.m.VerifyAll()
546 550
 
@@ -607,10 +611,10 @@ class L2PolicyTest(HeatTestCase):
607 611
         }).AndReturn({'l2_policy': {'id': '5678'}})
608 612
 
609 613
         snippet = template_format.parse(l2_policy_template)
610
-        stack = utils.parse_stack(snippet)
611
-        resource_defns = stack.t.resource_definitions(stack)
614
+        self.stack = utils.parse_stack(snippet)
615
+        resource_defns = self.stack.t.resource_definitions(self.stack)
612 616
         return grouppolicy.L2Policy(
613
-            'l2_policy', resource_defns['l2_policy'], stack)
617
+            'l2_policy', resource_defns['l2_policy'], self.stack)
614 618
 
615 619
     def test_create(self):
616 620
         rsrc = self.create_l2_policy()
@@ -631,16 +635,17 @@ class L2PolicyTest(HeatTestCase):
631 635
         self.m.ReplayAll()
632 636
 
633 637
         snippet = template_format.parse(l2_policy_template)
634
-        stack = utils.parse_stack(snippet)
635
-        resource_defns = stack.t.resource_definitions(stack)
638
+        self.stack = utils.parse_stack(snippet)
639
+        resource_defns = self.stack.t.resource_definitions(self.stack)
636 640
         rsrc = grouppolicy.L2Policy(
637
-            'l2_policy', resource_defns['l2_policy'], stack)
641
+            'l2_policy', resource_defns['l2_policy'], self.stack)
638 642
 
639 643
         error = self.assertRaises(exception.ResourceFailure,
640 644
                                   scheduler.TaskRunner(rsrc.create))
641 645
         self.assertEqual(
642
-            'NeutronClientException: An unknown exception occurred.',
643
-            str(error))
646
+            'NeutronClientException: resources.l2_policy: '
647
+            'An unknown exception occurred.',
648
+            six.text_type(error))
644 649
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
645 650
         self.m.VerifyAll()
646 651
 
@@ -677,8 +682,9 @@ class L2PolicyTest(HeatTestCase):
677 682
         error = self.assertRaises(exception.ResourceFailure,
678 683
                                   scheduler.TaskRunner(rsrc.delete))
679 684
         self.assertEqual(
680
-            'NeutronClientException: An unknown exception occurred.',
681
-            str(error))
685
+            'NeutronClientException: resources.l2_policy: '
686
+            'An unknown exception occurred.',
687
+            six.text_type(error))
682 688
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
683 689
         self.m.VerifyAll()
684 690
 
@@ -719,10 +725,10 @@ class L3PolicyTest(HeatTestCase):
719 725
         }).AndReturn({'l3_policy': {'id': '5678'}})
720 726
 
721 727
         snippet = template_format.parse(l3_policy_template)
722
-        stack = utils.parse_stack(snippet)
723
-        resource_defns = stack.t.resource_definitions(stack)
728
+        self.stack = utils.parse_stack(snippet)
729
+        resource_defns = self.stack.t.resource_definitions(self.stack)
724 730
         return grouppolicy.L3Policy(
725
-            'l3_policy', resource_defns['l3_policy'], stack)
731
+            'l3_policy', resource_defns['l3_policy'], self.stack)
726 732
 
727 733
     def test_create(self):
728 734
         rsrc = self.create_l3_policy()
@@ -745,16 +751,17 @@ class L3PolicyTest(HeatTestCase):
745 751
         self.m.ReplayAll()
746 752
 
747 753
         snippet = template_format.parse(l3_policy_template)
748
-        stack = utils.parse_stack(snippet)
749
-        resource_defns = stack.t.resource_definitions(stack)
754
+        self.stack = utils.parse_stack(snippet)
755
+        resource_defns = self.stack.t.resource_definitions(self.stack)
750 756
         rsrc = grouppolicy.L3Policy(
751
-            'l3_policy', resource_defns['l3_policy'], stack)
757
+            'l3_policy', resource_defns['l3_policy'], self.stack)
752 758
 
753 759
         error = self.assertRaises(exception.ResourceFailure,
754 760
                                   scheduler.TaskRunner(rsrc.create))
755 761
         self.assertEqual(
756
-            'NeutronClientException: An unknown exception occurred.',
757
-            str(error))
762
+            'NeutronClientException: resources.l3_policy: '
763
+            'An unknown exception occurred.',
764
+            six.text_type(error))
758 765
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
759 766
         self.m.VerifyAll()
760 767
 
@@ -791,8 +798,9 @@ class L3PolicyTest(HeatTestCase):
791 798
         error = self.assertRaises(exception.ResourceFailure,
792 799
                                   scheduler.TaskRunner(rsrc.delete))
793 800
         self.assertEqual(
794
-            'NeutronClientException: An unknown exception occurred.',
795
-            str(error))
801
+            'NeutronClientException: resources.l3_policy: '
802
+            'An unknown exception occurred.',
803
+            six.text_type(error))
796 804
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
797 805
         self.m.VerifyAll()
798 806
 
@@ -837,10 +845,11 @@ class PolicyClassifierTest(HeatTestCase):
837 845
         }).AndReturn({'policy_classifier': {'id': '5678'}})
838 846
 
839 847
         snippet = template_format.parse(policy_classifier_template)
840
-        stack = utils.parse_stack(snippet)
841
-        resource_defns = stack.t.resource_definitions(stack)
848
+        self.stack = utils.parse_stack(snippet)
849
+        resource_defns = self.stack.t.resource_definitions(self.stack)
842 850
         return grouppolicy.PolicyClassifier(
843
-            'policy_classifier', resource_defns['policy_classifier'], stack)
851
+            'policy_classifier', resource_defns['policy_classifier'],
852
+            self.stack)
844 853
 
845 854
     def test_create(self):
846 855
         rsrc = self.create_policy_classifier()
@@ -863,16 +872,18 @@ class PolicyClassifierTest(HeatTestCase):
863 872
         self.m.ReplayAll()
864 873
 
865 874
         snippet = template_format.parse(policy_classifier_template)
866
-        stack = utils.parse_stack(snippet)
867
-        resource_defns = stack.t.resource_definitions(stack)
875
+        self.stack = utils.parse_stack(snippet)
876
+        resource_defns = self.stack.t.resource_definitions(self.stack)
868 877
         rsrc = grouppolicy.PolicyClassifier(
869
-            'policy_classifier', resource_defns['policy_classifier'], stack)
878
+            'policy_classifier', resource_defns['policy_classifier'],
879
+            self.stack)
870 880
 
871 881
         error = self.assertRaises(exception.ResourceFailure,
872 882
                                   scheduler.TaskRunner(rsrc.create))
873 883
         self.assertEqual(
874
-            'NeutronClientException: An unknown exception occurred.',
875
-            str(error))
884
+            'NeutronClientException: resources.policy_classifier: '
885
+            'An unknown exception occurred.',
886
+            six.text_type(error))
876 887
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
877 888
         self.m.VerifyAll()
878 889
 
@@ -909,8 +920,9 @@ class PolicyClassifierTest(HeatTestCase):
909 920
         error = self.assertRaises(exception.ResourceFailure,
910 921
                                   scheduler.TaskRunner(rsrc.delete))
911 922
         self.assertEqual(
912
-            'NeutronClientException: An unknown exception occurred.',
913
-            str(error))
923
+            'NeutronClientException: resources.policy_classifier: '
924
+            'An unknown exception occurred.',
925
+            six.text_type(error))
914 926
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
915 927
         self.m.VerifyAll()
916 928
 
@@ -950,10 +962,10 @@ class PolicyActionTest(HeatTestCase):
950 962
         }).AndReturn({'policy_action': {'id': '5678'}})
951 963
 
952 964
         snippet = template_format.parse(policy_action_template)
953
-        stack = utils.parse_stack(snippet)
954
-        resource_defns = stack.t.resource_definitions(stack)
965
+        self.stack = utils.parse_stack(snippet)
966
+        resource_defns = self.stack.t.resource_definitions(self.stack)
955 967
         return grouppolicy.PolicyAction(
956
-            'policy_action', resource_defns['policy_action'], stack)
968
+            'policy_action', resource_defns['policy_action'], self.stack)
957 969
 
958 970
     def test_create(self):
959 971
         rsrc = self.create_policy_action()
@@ -975,16 +987,17 @@ class PolicyActionTest(HeatTestCase):
975 987
         self.m.ReplayAll()
976 988
 
977 989
         snippet = template_format.parse(policy_action_template)
978
-        stack = utils.parse_stack(snippet)
979
-        resource_defns = stack.t.resource_definitions(stack)
990
+        self.stack = utils.parse_stack(snippet)
991
+        resource_defns = self.stack.t.resource_definitions(self.stack)
980 992
         rsrc = grouppolicy.PolicyAction(
981
-            'policy_action', resource_defns['policy_action'], stack)
993
+            'policy_action', resource_defns['policy_action'], self.stack)
982 994
 
983 995
         error = self.assertRaises(exception.ResourceFailure,
984 996
                                   scheduler.TaskRunner(rsrc.create))
985 997
         self.assertEqual(
986
-            'NeutronClientException: An unknown exception occurred.',
987
-            str(error))
998
+            'NeutronClientException: resources.policy_action: '
999
+            'An unknown exception occurred.',
1000
+            six.text_type(error))
988 1001
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
989 1002
         self.m.VerifyAll()
990 1003
 
@@ -1021,8 +1034,9 @@ class PolicyActionTest(HeatTestCase):
1021 1034
         error = self.assertRaises(exception.ResourceFailure,
1022 1035
                                   scheduler.TaskRunner(rsrc.delete))
1023 1036
         self.assertEqual(
1024
-            'NeutronClientException: An unknown exception occurred.',
1025
-            str(error))
1037
+            'NeutronClientException: resources.policy_action: '
1038
+            'An unknown exception occurred.',
1039
+            six.text_type(error))
1026 1040
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1027 1041
         self.m.VerifyAll()
1028 1042
 
@@ -1063,10 +1077,10 @@ class PolicyRuleTest(HeatTestCase):
1063 1077
         }).AndReturn({'policy_rule': {'id': '5678'}})
1064 1078
 
1065 1079
         snippet = template_format.parse(policy_rule_template)
1066
-        stack = utils.parse_stack(snippet)
1067
-        resource_defns = stack.t.resource_definitions(stack)
1080
+        self.stack = utils.parse_stack(snippet)
1081
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1068 1082
         return grouppolicy.PolicyRule(
1069
-            'policy_rule', resource_defns['policy_rule'], stack)
1083
+            'policy_rule', resource_defns['policy_rule'], self.stack)
1070 1084
 
1071 1085
     def test_create(self):
1072 1086
         rsrc = self.create_policy_rule()
@@ -1089,16 +1103,17 @@ class PolicyRuleTest(HeatTestCase):
1089 1103
         self.m.ReplayAll()
1090 1104
 
1091 1105
         snippet = template_format.parse(policy_rule_template)
1092
-        stack = utils.parse_stack(snippet)
1093
-        resource_defns = stack.t.resource_definitions(stack)
1106
+        self.stack = utils.parse_stack(snippet)
1107
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1094 1108
         rsrc = grouppolicy.PolicyRule(
1095
-            'policy_rule', resource_defns['policy_rule'], stack)
1109
+            'policy_rule', resource_defns['policy_rule'], self.stack)
1096 1110
 
1097 1111
         error = self.assertRaises(exception.ResourceFailure,
1098 1112
                                   scheduler.TaskRunner(rsrc.create))
1099 1113
         self.assertEqual(
1100
-            'NeutronClientException: An unknown exception occurred.',
1101
-            str(error))
1114
+            'NeutronClientException: resources.policy_rule: '
1115
+            'An unknown exception occurred.',
1116
+            six.text_type(error))
1102 1117
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1103 1118
         self.m.VerifyAll()
1104 1119
 
@@ -1135,8 +1150,9 @@ class PolicyRuleTest(HeatTestCase):
1135 1150
         error = self.assertRaises(exception.ResourceFailure,
1136 1151
                                   scheduler.TaskRunner(rsrc.delete))
1137 1152
         self.assertEqual(
1138
-            'NeutronClientException: An unknown exception occurred.',
1139
-            str(error))
1153
+            'NeutronClientException: resources.policy_rule: '
1154
+            'An unknown exception occurred.',
1155
+            six.text_type(error))
1140 1156
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1141 1157
         self.m.VerifyAll()
1142 1158
 
@@ -1177,10 +1193,10 @@ class PolicyRuleSetTest(HeatTestCase):
1177 1193
         }).AndReturn({'policy_rule_set': {'id': '5678'}})
1178 1194
 
1179 1195
         snippet = template_format.parse(policy_rule_set_template)
1180
-        stack = utils.parse_stack(snippet)
1181
-        resource_defns = stack.t.resource_definitions(stack)
1196
+        self.stack = utils.parse_stack(snippet)
1197
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1182 1198
         return grouppolicy.PolicyRuleSet(
1183
-            'policy_rule_set', resource_defns['policy_rule_set'], stack)
1199
+            'policy_rule_set', resource_defns['policy_rule_set'], self.stack)
1184 1200
 
1185 1201
     def test_create(self):
1186 1202
         rsrc = self.create_policy_rule_set()
@@ -1203,16 +1219,17 @@ class PolicyRuleSetTest(HeatTestCase):
1203 1219
         self.m.ReplayAll()
1204 1220
 
1205 1221
         snippet = template_format.parse(policy_rule_set_template)
1206
-        stack = utils.parse_stack(snippet)
1207
-        resource_defns = stack.t.resource_definitions(stack)
1222
+        self.stack = utils.parse_stack(snippet)
1223
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1208 1224
         rsrc = grouppolicy.PolicyRuleSet(
1209
-            'policy_rule_set', resource_defns['policy_rule_set'], stack)
1225
+            'policy_rule_set', resource_defns['policy_rule_set'], self.stack)
1210 1226
 
1211 1227
         error = self.assertRaises(exception.ResourceFailure,
1212 1228
                                   scheduler.TaskRunner(rsrc.create))
1213 1229
         self.assertEqual(
1214
-            'NeutronClientException: An unknown exception occurred.',
1215
-            str(error))
1230
+            'NeutronClientException: resources.policy_rule_set: '
1231
+            'An unknown exception occurred.',
1232
+            six.text_type(error))
1216 1233
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1217 1234
         self.m.VerifyAll()
1218 1235
 
@@ -1249,8 +1266,9 @@ class PolicyRuleSetTest(HeatTestCase):
1249 1266
         error = self.assertRaises(exception.ResourceFailure,
1250 1267
                                   scheduler.TaskRunner(rsrc.delete))
1251 1268
         self.assertEqual(
1252
-            'NeutronClientException: An unknown exception occurred.',
1253
-            str(error))
1269
+            'NeutronClientException: resources.policy_rule_set: '
1270
+            'An unknown exception occurred.',
1271
+            six.text_type(error))
1254 1272
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1255 1273
         self.m.VerifyAll()
1256 1274
 
@@ -1295,11 +1313,11 @@ class NetworkServicePolicyTest(HeatTestCase):
1295 1313
         }).AndReturn({'network_service_policy': {'id': '5678'}})
1296 1314
 
1297 1315
         snippet = template_format.parse(network_service_policy_template)
1298
-        stack = utils.parse_stack(snippet)
1299
-        resource_defns = stack.t.resource_definitions(stack)
1316
+        self.stack = utils.parse_stack(snippet)
1317
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1300 1318
         return grouppolicy.NetworkServicePolicy(
1301 1319
             'network_service_policy',
1302
-            resource_defns['network_service_policy'], stack)
1320
+            resource_defns['network_service_policy'], self.stack)
1303 1321
 
1304 1322
     def test_create(self):
1305 1323
         rsrc = self.create_network_service_policy()
@@ -1322,17 +1340,18 @@ class NetworkServicePolicyTest(HeatTestCase):
1322 1340
         self.m.ReplayAll()
1323 1341
 
1324 1342
         snippet = template_format.parse(network_service_policy_template)
1325
-        stack = utils.parse_stack(snippet)
1326
-        resource_defns = stack.t.resource_definitions(stack)
1343
+        self.stack = utils.parse_stack(snippet)
1344
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1327 1345
         rsrc = grouppolicy.NetworkServicePolicy(
1328 1346
             'network_service_policy',
1329
-            resource_defns['network_service_policy'], stack)
1347
+            resource_defns['network_service_policy'], self.stack)
1330 1348
 
1331 1349
         error = self.assertRaises(exception.ResourceFailure,
1332 1350
                                   scheduler.TaskRunner(rsrc.create))
1333 1351
         self.assertEqual(
1334
-            'NeutronClientException: An unknown exception occurred.',
1335
-            str(error))
1352
+            'NeutronClientException: resources.network_service_policy: '
1353
+            'An unknown exception occurred.',
1354
+            six.text_type(error))
1336 1355
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1337 1356
         self.m.VerifyAll()
1338 1357
 
@@ -1369,8 +1388,9 @@ class NetworkServicePolicyTest(HeatTestCase):
1369 1388
         error = self.assertRaises(exception.ResourceFailure,
1370 1389
                                   scheduler.TaskRunner(rsrc.delete))
1371 1390
         self.assertEqual(
1372
-            'NeutronClientException: An unknown exception occurred.',
1373
-            str(error))
1391
+            'NeutronClientException: resources.network_service_policy: '
1392
+            'An unknown exception occurred.',
1393
+            six.text_type(error))
1374 1394
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1375 1395
         self.m.VerifyAll()
1376 1396
 
@@ -1423,11 +1443,11 @@ class ExternalPolicyTest(HeatTestCase):
1423 1443
         }).AndReturn({'external_policy': {'id': '5678'}})
1424 1444
 
1425 1445
         snippet = template_format.parse(external_policy_template)
1426
-        stack = utils.parse_stack(snippet)
1427
-        resource_defns = stack.t.resource_definitions(stack)
1446
+        self.stack = utils.parse_stack(snippet)
1447
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1428 1448
         return grouppolicy.ExternalPolicy(
1429 1449
             'external_policy',
1430
-            resource_defns['external_policy'], stack)
1450
+            resource_defns['external_policy'], self.stack)
1431 1451
 
1432 1452
     def test_create(self):
1433 1453
         rsrc = self.create_external_policy()
@@ -1456,17 +1476,18 @@ class ExternalPolicyTest(HeatTestCase):
1456 1476
         self.m.ReplayAll()
1457 1477
 
1458 1478
         snippet = template_format.parse(external_policy_template)
1459
-        stack = utils.parse_stack(snippet)
1460
-        resource_defns = stack.t.resource_definitions(stack)
1479
+        self.stack = utils.parse_stack(snippet)
1480
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1461 1481
         rsrc = grouppolicy.ExternalPolicy(
1462 1482
             'external_policy',
1463
-            resource_defns['external_policy'], stack)
1483
+            resource_defns['external_policy'], self.stack)
1464 1484
 
1465 1485
         error = self.assertRaises(exception.ResourceFailure,
1466 1486
                                   scheduler.TaskRunner(rsrc.create))
1467 1487
         self.assertEqual(
1468
-            'NeutronClientException: An unknown exception occurred.',
1469
-            str(error))
1488
+            'NeutronClientException: resources.external_policy: '
1489
+            'An unknown exception occurred.',
1490
+            six.text_type(error))
1470 1491
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1471 1492
         self.m.VerifyAll()
1472 1493
 
@@ -1503,8 +1524,9 @@ class ExternalPolicyTest(HeatTestCase):
1503 1524
         error = self.assertRaises(exception.ResourceFailure,
1504 1525
                                   scheduler.TaskRunner(rsrc.delete))
1505 1526
         self.assertEqual(
1506
-            'NeutronClientException: An unknown exception occurred.',
1507
-            str(error))
1527
+            'NeutronClientException: resources.external_policy: '
1528
+            'An unknown exception occurred.',
1529
+            six.text_type(error))
1508 1530
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1509 1531
         self.m.VerifyAll()
1510 1532
 
@@ -1582,11 +1604,11 @@ class ExternalSegmentTest(HeatTestCase):
1582 1604
         }).AndReturn({'external_segment': {'id': '5678'}})
1583 1605
 
1584 1606
         snippet = template_format.parse(external_segment_template)
1585
-        stack = utils.parse_stack(snippet)
1586
-        resource_defns = stack.t.resource_definitions(stack)
1607
+        self.stack = utils.parse_stack(snippet)
1608
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1587 1609
         return grouppolicy.ExternalSegment(
1588 1610
             'external_segment',
1589
-            resource_defns['external_segment'], stack)
1611
+            resource_defns['external_segment'], self.stack)
1590 1612
 
1591 1613
     def test_create(self):
1592 1614
         rsrc = self.create_external_segment()
@@ -1614,17 +1636,18 @@ class ExternalSegmentTest(HeatTestCase):
1614 1636
         self.m.ReplayAll()
1615 1637
 
1616 1638
         snippet = template_format.parse(external_segment_template)
1617
-        stack = utils.parse_stack(snippet)
1618
-        resource_defns = stack.t.resource_definitions(stack)
1639
+        self.stack = utils.parse_stack(snippet)
1640
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1619 1641
         rsrc = grouppolicy.ExternalSegment(
1620 1642
             'external_segment',
1621
-            resource_defns['external_segment'], stack)
1643
+            resource_defns['external_segment'], self.stack)
1622 1644
 
1623 1645
         error = self.assertRaises(exception.ResourceFailure,
1624 1646
                                   scheduler.TaskRunner(rsrc.create))
1625 1647
         self.assertEqual(
1626
-            'NeutronClientException: An unknown exception occurred.',
1627
-            str(error))
1648
+            'NeutronClientException: resources.external_segment: '
1649
+            'An unknown exception occurred.',
1650
+            six.text_type(error))
1628 1651
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1629 1652
         self.m.VerifyAll()
1630 1653
 
@@ -1661,8 +1684,9 @@ class ExternalSegmentTest(HeatTestCase):
1661 1684
         error = self.assertRaises(exception.ResourceFailure,
1662 1685
                                   scheduler.TaskRunner(rsrc.delete))
1663 1686
         self.assertEqual(
1664
-            'NeutronClientException: An unknown exception occurred.',
1665
-            str(error))
1687
+            'NeutronClientException: resources.external_segment: '
1688
+            'An unknown exception occurred.',
1689
+            six.text_type(error))
1666 1690
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1667 1691
         self.m.VerifyAll()
1668 1692
 
@@ -1708,11 +1732,11 @@ class NATPoolTest(HeatTestCase):
1708 1732
         }).AndReturn({'nat_pool': {'id': '5678'}})
1709 1733
 
1710 1734
         snippet = template_format.parse(nat_pool_template)
1711
-        stack = utils.parse_stack(snippet)
1712
-        resource_defns = stack.t.resource_definitions(stack)
1735
+        self.stack = utils.parse_stack(snippet)
1736
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1713 1737
         return grouppolicy.NATPool(
1714 1738
             'nat_pool',
1715
-            resource_defns['nat_pool'], stack)
1739
+            resource_defns['nat_pool'], self.stack)
1716 1740
 
1717 1741
     def test_create(self):
1718 1742
         rsrc = self.create_nat_pool()
@@ -1735,17 +1759,18 @@ class NATPoolTest(HeatTestCase):
1735 1759
         self.m.ReplayAll()
1736 1760
 
1737 1761
         snippet = template_format.parse(nat_pool_template)
1738
-        stack = utils.parse_stack(snippet)
1739
-        resource_defns = stack.t.resource_definitions(stack)
1762
+        self.stack = utils.parse_stack(snippet)
1763
+        resource_defns = self.stack.t.resource_definitions(self.stack)
1740 1764
         rsrc = grouppolicy.NATPool(
1741 1765
             'nat_pool',
1742
-            resource_defns['nat_pool'], stack)
1766
+            resource_defns['nat_pool'], self.stack)
1743 1767
 
1744 1768
         error = self.assertRaises(exception.ResourceFailure,
1745 1769
                                   scheduler.TaskRunner(rsrc.create))
1746 1770
         self.assertEqual(
1747
-            'NeutronClientException: An unknown exception occurred.',
1748
-            str(error))
1771
+            'NeutronClientException: resources.nat_pool: '
1772
+            'An unknown exception occurred.',
1773
+            six.text_type(error))
1749 1774
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
1750 1775
         self.m.VerifyAll()
1751 1776
 
@@ -1782,8 +1807,9 @@ class NATPoolTest(HeatTestCase):
1782 1807
         error = self.assertRaises(exception.ResourceFailure,
1783 1808
                                   scheduler.TaskRunner(rsrc.delete))
1784 1809
         self.assertEqual(
1785
-            'NeutronClientException: An unknown exception occurred.',
1786
-            str(error))
1810
+            'NeutronClientException: resources.nat_pool: '
1811
+            'An unknown exception occurred.',
1812
+            six.text_type(error))
1787 1813
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
1788 1814
         self.m.VerifyAll()
1789 1815
 

+ 29
- 20
gbpautomation/heat/tests/test_servicechain.py View File

@@ -11,6 +11,7 @@
11 11
 #    under the License.
12 12
 
13 13
 import copy
14
+import six
14 15
 
15 16
 from gbpautomation.heat.engine.resources import servicechain
16 17
 from gbpclient.v2_0 import client as gbpclient
@@ -81,10 +82,11 @@ class ServiceChainNodeTest(HeatTestCase):
81 82
         }).AndReturn({'servicechain_node': {'id': '5678'}})
82 83
 
83 84
         snippet = template_format.parse(servicechain_node_template)
84
-        stack = utils.parse_stack(snippet)
85
-        resource_defns = stack.t.resource_definitions(stack)
85
+        self.stack = utils.parse_stack(snippet)
86
+        resource_defns = self.stack.t.resource_definitions(self.stack)
86 87
         return servicechain.ServiceChainNode(
87
-            'servicechain_node', resource_defns['servicechain_node'], stack)
88
+            'servicechain_node', resource_defns['servicechain_node'],
89
+            self.stack)
88 90
 
89 91
     def test_create(self):
90 92
         rsrc = self.create_servicechain_node()
@@ -105,16 +107,18 @@ class ServiceChainNodeTest(HeatTestCase):
105 107
         self.m.ReplayAll()
106 108
 
107 109
         snippet = template_format.parse(servicechain_node_template)
108
-        stack = utils.parse_stack(snippet)
109
-        resource_defns = stack.t.resource_definitions(stack)
110
+        self.stack = utils.parse_stack(snippet)
111
+        resource_defns = self.stack.t.resource_definitions(self.stack)
110 112
         rsrc = servicechain.ServiceChainNode(
111
-            'servicechain_node', resource_defns['servicechain_node'], stack)
113
+            'servicechain_node', resource_defns['servicechain_node'],
114
+            self.stack)
112 115
 
113 116
         error = self.assertRaises(exception.ResourceFailure,
114 117
                                   scheduler.TaskRunner(rsrc.create))
115 118
         self.assertEqual(
116
-            'NeutronClientException: An unknown exception occurred.',
117
-            str(error))
119
+            'NeutronClientException: resources.servicechain_node: '
120
+            'An unknown exception occurred.',
121
+            six.text_type(error))
118 122
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
119 123
         self.m.VerifyAll()
120 124
 
@@ -151,8 +155,9 @@ class ServiceChainNodeTest(HeatTestCase):
151 155
         error = self.assertRaises(exception.ResourceFailure,
152 156
                                   scheduler.TaskRunner(rsrc.delete))
153 157
         self.assertEqual(
154
-            'NeutronClientException: An unknown exception occurred.',
155
-            str(error))
158
+            'NeutronClientException: resources.servicechain_node: '
159
+            'An unknown exception occurred.',
160
+            six.text_type(error))
156 161
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
157 162
         self.m.VerifyAll()
158 163
 
@@ -190,10 +195,11 @@ class ServiceChainSpecTest(HeatTestCase):
190 195
         }).AndReturn({'servicechain_spec': {'id': '5678'}})
191 196
 
192 197
         snippet = template_format.parse(servicechain_spec_template)
193
-        stack = utils.parse_stack(snippet)
194
-        resource_defns = stack.t.resource_definitions(stack)
198
+        self.stack = utils.parse_stack(snippet)
199
+        resource_defns = self.stack.t.resource_definitions(self.stack)
195 200
         return servicechain.ServiceChainSpec(
196
-            'servicechain_spec', resource_defns['servicechain_spec'], stack)
201
+            'servicechain_spec', resource_defns['servicechain_spec'],
202
+            self.stack)
197 203
 
198 204
     def test_create(self):
199 205
         rsrc = self.create_servicechain_spec()
@@ -213,16 +219,18 @@ class ServiceChainSpecTest(HeatTestCase):
213 219
         self.m.ReplayAll()
214 220
 
215 221
         snippet = template_format.parse(servicechain_spec_template)
216
-        stack = utils.parse_stack(snippet)
217
-        resource_defns = stack.t.resource_definitions(stack)
222
+        self.stack = utils.parse_stack(snippet)
223
+        resource_defns = self.stack.t.resource_definitions(self.stack)
218 224
         rsrc = servicechain.ServiceChainSpec(
219
-            'servicechain_spec', resource_defns['servicechain_spec'], stack)
225
+            'servicechain_spec', resource_defns['servicechain_spec'],
226
+            self.stack)
220 227
 
221 228
         error = self.assertRaises(exception.ResourceFailure,
222 229
                                   scheduler.TaskRunner(rsrc.create))
223 230
         self.assertEqual(
224
-            'NeutronClientException: An unknown exception occurred.',
225
-            str(error))
231
+            'NeutronClientException: resources.servicechain_spec: '
232
+            'An unknown exception occurred.',
233
+            six.text_type(error))
226 234
         self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
227 235
         self.m.VerifyAll()
228 236
 
@@ -259,8 +267,9 @@ class ServiceChainSpecTest(HeatTestCase):
259 267
         error = self.assertRaises(exception.ResourceFailure,
260 268
                                   scheduler.TaskRunner(rsrc.delete))
261 269
         self.assertEqual(
262
-            'NeutronClientException: An unknown exception occurred.',
263
-            str(error))
270
+            'NeutronClientException: resources.servicechain_spec: '
271
+            'An unknown exception occurred.',
272
+            six.text_type(error))
264 273
         self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
265 274
         self.m.VerifyAll()
266 275
 

Loading…
Cancel
Save