How to use safe_load method in molecule

Best Python code snippet using molecule_python

action_test_params.py

Source:action_test_params.py Github

copy

Full Screen

1import yaml2CREATE_OBJECTS_DICT = yaml.safe_load("""3actions:4- Create-object:5 Type: Enterprise6 Actions:7 - Create-object:8 Select-by-field: test_select_19 Type: DomainTemplate10 - Create-object:11 Select-by-field: test_select_212 Type: Domain13- create-object:14 type: Enterprise15 actions:16 - create-object:17 select-by-field: test_select_318 type: DomainTemplate19 - create-object:20 select-by-field: test_select_421 type: Domain22""")23CREATE_OBJECTS_NO_TYPE = yaml.safe_load("""24actions:25- Create-object:26 Missing-type: Invalid27""")28CREATE_OBJECTS_SELECT_FIRST = yaml.safe_load("""29actions:30- Create-object:31 Select-By-field: $First32 Type: Level133 Actions:34 - Create-object:35 Type: Level236 Actions:37 - Set-values:38 name: L2-O139""")40CREATE_OBJECTS_SELECT_LAST = yaml.safe_load("""41actions:42- Create-object:43 Select-By-field: $Last44 Type: Level145 Actions:46 - Create-object:47 Type: Level248 Actions:49 - Set-values:50 name: L2-O151""")52FIND_NO_SELECT = yaml.safe_load("""53actions:54- Select-object:55 By-field: $child56 Type: Level157 Value: NoMatch58 Actions:59 - Create-object:60 Actions:61 - Set-values:62 name: L2-O163 Type: Level264 - Select-object:65 By-field: name66 Type: Find67 Value: L2-O268""")69FIND_SINGLE_LEVEL = yaml.safe_load("""70actions:71- Select-object:72 By-field: $child73 Type: Level174 Value: find75 Actions:76 - Create-object:77 Type: Level278 Actions:79 - Set-values:80 name: L2-O181 - Select-object:82 By-field: name83 Type: Find84 Value: L2-O285""")86FIND_TREE = yaml.safe_load("""87actions:88- Select-object:89 By-field: $child90 Type: Level191 Value: level292 Actions:93 - Select-object:94 By-field: $child95 Type: Level296 Value: find97 Actions:98 - Create-object:99 Actions:100 - Set-values:101 name: L3-O1102 Type: Level3103 - Select-object:104 By-field: name105 Type: Find106 Value: L3-O2107""")108INVALID_ACTION_1 = yaml.safe_load("""109actions:110- Create-object:111 Type: Enterprise112 Actions:113 - not a dict114""")115INVALID_ACTION_2 = yaml.safe_load("""116actions:117- Create-object:118 Type: Enterprise119 Actions:120 - bad-type: {}121""")122INVALID_ACTION_3 = yaml.safe_load("""123actions:124- Create-object:125 Type: Enterprise126 Actions:127 - Create-object:128 Select-by-field: test_select_1129 Type: DomainTemplate130 select-object: multiple131""")132ORDER_CREATE = yaml.safe_load("""133actions:134- Create-object:135 Type: Level1136 Actions:137 - Create-object:138 Select-by-field: field1139 Type: Level2140 Actions:141 - Set-values:142 field1: L2-O1143 - Create-object:144 Select-by-field: field1145 Type: Level2146 Actions:147 - Set-values:148 field1: L2-O2149 - Set-values:150 field1: value1151 name: L1-O1152""")153ORDER_DISABLE_COMBINE_1 = yaml.safe_load("""154actions:155- Create-object:156 Type: Level1157 Actions:158 - Set-values:159 name: L1-O1160 - Store-value:161 As-name: store_1162 from-field: name163- Create-object:164 Type: Level1165 Actions:166 - Set-values:167 name: L1-O2168 - Create-object:169 Type: Level2170 Actions:171 - Set-values:172 name: L2-O1173 - Store-value:174 As-name: store_2175 From-field: field1176 - Create-object:177 Type: Level2178 Actions:179 - Set-values:180 name: L2-O2181 - Retrieve-value:182 From-name: store_1183 To-field: field1184""")185ORDER_DISABLE_COMBINE_2 = yaml.safe_load("""186actions:187- Select-object:188 By-field: name189 Disable-combine: true190 Type: Level1191 Value: L1-O1192 Actions:193 - Create-object:194 Type: Level2195 Actions:196 - Set-values:197 name: L2-O3198 - Retrieve-value:199 From-name: store_2200 To-field: field1201""")202ORDER_MULTI_CREATE = yaml.safe_load("""203actions:204- Create-object:205 Type: Level1206 Actions:207 - Create-object:208 Select-by-field: field1209 Type: Level2210 Actions:211 - Set-values:212 field1: L2-O1213 field2: value2214 - Create-object:215 Select-by-field: field1216 Type: Level2217 Actions:218 - Set-values:219 field1: L2-O2220 field2: value2221 - Set-values:222 field1: value1223 name: L1-O1224""")225ORDER_MULTI_SELECT_1 = yaml.safe_load("""226actions:227- Select-object:228 By-field:229 - name230 - field1231 Type: Level1232 Value:233 - L1-O1234 - value1235 Actions:236 - Select-object:237 By-field:238 - field1239 - field2240 Type: Level2241 Value:242 - L2-O2243 - value2244 Actions:245 - Set-values:246 field3: value3247 - Create-object:248 Select-by-field: field1249 Type: Level3250 Actions:251 - Set-values:252 field1: L3-O1253 - Create-object:254 Select-by-field: field1255 Type: Level2256 Actions:257 - Set-values:258 field1: L2-O3259 field2: value2260 - Set-values:261 field2: value2262""")263ORDER_MULTI_SELECT_2 = yaml.safe_load("""264actions:265- Select-object:266 Type: Level1267 By-field:268 - field1269 - name270 Value:271 - value1272 - L1-O1273 Actions:274 - Select-object:275 Type: Level2276 By-field:277 - field1278 - field2279 Value:280 - L2-O3281 - value2282 Actions:283 - Set-values:284 field3: value3285 - Create-object:286 Select-by-field: field1287 Type: Level3288 Actions:289 - Set-values:290 field1: L3-O2291 - Create-object:292 Type: Level2293 Select-by-field: field1294 Actions:295 - Set-values:296 field1: L2-O4297 - Set-values:298 field3: value3299""")300ORDER_SELECT_1 = yaml.safe_load("""301actions:302- Select-object:303 By-field: name304 Type: Level1305 Value: L1-O1306 Actions:307 - Select-object:308 By-field: field1309 Type: Level2310 Value: L2-O2311 Actions:312 - Set-values:313 field2: value2314 - Create-object:315 Select-by-field: field1316 Type: Level3317 Actions:318 - Set-values:319 field1: L3-O1320 - Create-object:321 Select-by-field: field1322 Type: Level2323 Actions:324 - Set-values:325 field1: L2-O3326 - Set-values:327 field2: value2328""")329ORDER_SELECT_CONFLICT1 = yaml.safe_load("""330actions:331- Select-object:332 By-field: name333 Type: Level1334 Value: L1-O1335 Actions:336 - Select-object:337 By-field: field1338 Type: Level2339 Value: L2-O2340 Actions:341 - Set-values:342 field2: value2343 - Create-object:344 Select-by-field: field1345 Type: Level3346 Actions:347 - Set-values:348 field1: L3-O1349 - Create-object:350 Select-by-field: field1351 Type: Level2352 Actions:353 - Set-values:354 field1: L2-O3355 - Set-values:356 field2: value4357""")358ORDER_SELECT_2 = yaml.safe_load("""359actions:360- Select-object:361 By-field: field1362 Type: Level1363 Value: value1364 Actions:365 - Select-object:366 By-field: field1367 Type: Level2368 Value: L2-O3369 Actions:370 - Set-values:371 field3: value3372 - Create-object:373 Select-by-field: field1374 Type: Level3375 Actions:376 - Set-values:377 field1: L3-O2378 - Create-object:379 Select-by-field: field1380 Type: Level2381 Actions:382 - Set-values:383 field1: L2-O4384 - Set-values:385 field3: value3386""")387ORDER_STORE_1 = yaml.safe_load("""388actions:389- Create-object:390 Type: Level1391 Actions:392 - Set-values:393 name: L1-O1394 - Create-object:395 Type: Level2396 Actions:397 - Set-values:398 name: L2-O1399- Create-object:400 Type: Level1401 Actions:402 - Set-values:403 name: L1-O2404 - Create-object:405 Type: Level2406 Actions:407 - Set-values:408 name: L2-O2409 - Create-object:410 Type: Level2411 Actions:412 - Set-values:413 name: L2-O3414""")415ORDER_STORE_2 = yaml.safe_load("""416actions:417- Select-object:418 By-field: name419 Type: Level1420 Value: L1-O2421 Actions:422 - Select-object:423 By-field: name424 Type: Level2425 Value: L2-O2426 Actions:427 - Store-value:428 As-name: store_1429 from-field: field1430- Select-object:431 By-field: name432 Type: Level1433 Value: L1-O1434 Actions:435 - select-object:436 By-field: name437 Type: Level2438 Value: L2-O1439 Actions:440 - Retrieve-value:441 From-name: store_1442 To-field: field1443""")444ORDER_STORE_3 = yaml.safe_load("""445actions:446- Select-object:447 By-field: name448 Type: Level1449 Value: L1-O2450 Actions:451 - Select-object:452 By-field: name453 Type: Level2454 Value: L2-O3455 Actions:456 - Store-value:457 As-name: store_1458 from-field: field1459 - select-object:460 By-field: name461 Type: Level2462 Value: L2-O2463 Actions:464 - Retrieve-value:465 From-name: store_1466 To-field: field1467""")468ORDER_STORE_4 = yaml.safe_load("""469actions:470- Create-object:471 Type: Level1472 Actions:473 - Set-values:474 name: L1-O1475""")476ORDER_STORE_5 = yaml.safe_load("""477actions:478- Select-object:479 By-field: name480 Type: Level1481 Value: L1-O2482 Actions:483 - Store-value:484 As-name: store_1485 from-field: field1486- select-object:487 By-field: name488 Type: Level1489 Value: L1-O1490 Actions:491 - Create-object:492 Type: Level2493 Actions:494 - Set-values:495 name: L2-O1496 - Retrieve-value:497 From-name: store_1498 To-field: field1499""")500ORDER_OVERRIDE_1 = yaml.safe_load("""501actions:502- Select-object:503 By-field: name504 Type: Level1505 Value: L1-O1506 Actions:507 - Select-object:508 By-field: name509 Type: Level2510 Value: L2-O1511 Actions:512 - Store-value:513 As-name: store_1514 from-field: field1515- Select-object:516 By-field: name517 Type: Level1518 Value: L1-O2519 Actions:520 - Select-object:521 By-field: name522 Type: Level2523 Value: L2-O2524 Actions:525 - Set-values:526 name: L2-O2527- Select-object:528 By-field: name529 Type: Level1530 Value: L1-O3531 Actions:532 - select-object:533 By-field: name534 Type: Level2535 Value: L2-O3536 Actions:537 - Retrieve-value:538 From-name: store_1539 To-field: field1540""")541ORDER_OVERRIDE_2 = yaml.safe_load("""542actions:543- Select-object:544 By-field: name545 Type: Level1546 Value: L1-O4547 Order: 1548 Actions:549 - Select-object:550 By-field: name551 Type: Level2552 Value: L2-O4553 Actions:554 - Store-value:555 As-name: store_2556 from-field: field1557- Select-object:558 By-field: name559 Type: Level1560 Value: L1-O5561 Order: 1562 Actions:563 - Select-object:564 By-field: name565 Type: Level2566 Value: L2-O5567 Actions:568 - Set-values:569 name: L2-O5570- Select-object:571 By-field: name572 Type: Level1573 Value: L1-O6574 Order: 1575 Actions:576 - select-object:577 By-field: name578 Type: Level2579 Value: L2-O6580 Actions:581 - Retrieve-value:582 From-name: store_2583 To-field: field1584""")585ORDER_OVERRIDE_3 = yaml.safe_load("""586actions:587- Select-object:588 By-field: name589 Type: Level1590 Value: L1-O7591 Order: 9592 Actions:593 - Select-object:594 By-field: name595 Type: Level2596 Value: L2-O7597 Actions:598 - Store-value:599 As-name: store_3600 from-field: field1601- Select-object:602 By-field: name603 Type: Level1604 Value: L1-O8605 Order: 9606 Actions:607 - Select-object:608 By-field: name609 Type: Level2610 Value: L2-O8611 Actions:612 - Set-values:613 name: L2-O8614- Select-object:615 By-field: name616 Type: Level1617 Value: L1-O9618 Order: 9619 Actions:620 - select-object:621 By-field: name622 Type: Level2623 Value: L2-O9624 Actions:625 - Retrieve-value:626 From-name: store_3627 To-field: field1628""")629RETRIEVE_AS_LIST = yaml.safe_load("""630actions:631- Create-object:632 Type: Level1633 Actions:634 - Set-values:635 name: L1-O1636 - Store-value:637 As-name: store_1638 from-field: name639- Create-object:640 Type: Level1641 Actions:642 - Set-values:643 name: L1-O2644 - Store-value:645 As-name: store_2646 from-field: name647- Create-object:648 Type: Level1649 Actions:650 - Set-values:651 name: L1-O3652 - Retrieve-value:653 As-List: true654 From-name: store_1655 To-field: field1656 - Retrieve-value:657 As-List: true658 From-name: store_2659 To-field: field1660""")661RETRIEVE_DEPENDENCY_ONLY = yaml.safe_load("""662actions:663- Create-object:664 Type: Level1665 Actions:666 - Set-values:667 name: L1-O1668 - Store-value:669 As-name: store_1670 from-field: name671- Create-object:672 Type: Level1673 Actions:674 - Set-values:675 name: L1-O2676 - Retrieve-value:677 From-name: store_1678 To-field: $Dependency-Only679""")680RETRIEVE_CONFLICT_1 = yaml.safe_load("""681actions:682- Create-object:683 Type: Enterprise684 Actions:685 - create-object:686 type: DomainTemplate687 actions:688 - Set-values:689 name: domain1690 - Store-value:691 As-name: template_id692 from-field: id693 - Create-object:694 Type: Domain695 Actions:696 - Set-values:697 name: domain1698 templateid: id1699 - Retrieve-value:700 From-name: template_id701 To-field: templateID702""")703RETRIEVE_CONFLICT_2 = yaml.safe_load("""704actions:705- Create-object:706 Type: Enterprise707 Actions:708 - create-object:709 type: DomainTemplate710 actions:711 - Set-values:712 name: domain1713 - Store-value:714 As-name: template_id715 from-field: id716 - Create-object:717 Type: Domain718 Actions:719 - Retrieve-value:720 From-name: template_id721 To-field: templateID722 - Set-values:723 name: domain1724 templateid: id1725""")726RETRIEVE_BEFORE_STORE = yaml.safe_load("""727actions:728- Create-object:729 Type: Enterprise730 Actions:731 - create-object:732 type: Domain733 actions:734 - Set-values:735 name: domain1736 - Retrieve-value:737 From-name: template_id738 To-field: templateID739 - Create-object:740 Type: DomainTemplate741 Actions:742 - Store-value:743 As-name: template_id744 from-field: id745 - Set-values:746 name: domain_template747""")748RETRIEVE_NO_FIELD = yaml.safe_load("""749actions:750- Create-object:751 Type: Enterprise752 Actions:753 - Create-object:754 Type: Domain755 Actions:756 - Retrieve-value:757 From-name: template_id758 Missing-to-field: Invalid759""")760RETRIEVE_NO_OBJECT = yaml.safe_load("""761actions:762- Retrieve-value:763 from-name: template_id764 to-field: id765""")766RETRIEVE_NO_NAME = yaml.safe_load("""767actions:768- Create-object:769 Type: Enterprise770 Actions:771 - Create-object:772 Type: Domain773 Actions:774 - Retrieve-value:775 From-name: null776 to-field: id777""")778SELECT_MULTIPLE_MISSING = yaml.safe_load("""779actions:780- Select-object:781 Type: Level1782 By-field:783 - field1784 - field2785 Value:786 - value_1787 - value_4788 Actions:789 - Create-object:790 Type: Level2791 Actions:792 - Set-values:793 name: L2-O1794""")795SELECT_MULTIPLE_SUCCESS_1 = yaml.safe_load("""796actions:797- Select-object:798 Type: Level1799 By-field:800 - field1801 - field2802 Value:803 - value_1804 - value_2805 Actions:806 - Create-object:807 Type: Level2808 Actions:809 - Set-values:810 name: L2-O1811""")812SELECT_MULTIPLE_SUCCESS_2 = yaml.safe_load("""813actions:814- Select-object:815 Type: Level1816 By-field:817 - field1818 - field2819 Value:820 - value_3821 - value_4822 Actions:823 - Create-object:824 Type: Level2825 Actions:826 - Set-values:827 name: L2-O1828""")829SELECT_MULTIPLE_REVERT_SUCCESS_1 = yaml.safe_load("""830actions:831- Select-object:832 Type: Level1833 By-field:834 - field1835 - field2836 Value:837 - value_5838 - value_6839 Actions:840 - Create-object:841 Type: Level2842 Actions:843 - Set-values:844 name: L2-O1845""")846SELECT_MULTIPLE_REVERT_SUCCESS_2 = yaml.safe_load("""847actions:848- Select-object:849 Type: Level1850 By-field:851 - field1852 - field2853 Value:854 - value_7855 - value_8856 Actions:857 - Create-object:858 Type: Level2859 Actions:860 - Set-values:861 name: L2-O1862""")863SELECT_OBJECTS_BY_POSITION_FIRST = yaml.safe_load("""864actions:865- Select-object:866 Type: Level1867 By-field: $Position868 Value: 0869 Actions:870 - Create-object:871 Type: Level2872 Actions:873 - Set-values:874 name: L2-O1875""")876SELECT_OBJECTS_BY_POSITION_LAST = yaml.safe_load("""877actions:878- Select-object:879 By-field: $Position880 Type: Level1881 Value: -1882 Actions:883 - Create-object:884 Type: Level2885 Actions:886 - Set-values:887 name: L2-O1888""")889SELECT_OBJECTS_BY_POSITION_OOB = yaml.safe_load("""890actions:891- Select-object:892 By-field: $Position893 Type: Level1894 Value: 2895 Actions:896 - Create-object:897 Type: Level2898 Actions:899 - Set-values:900 name: L2-O1901""")902SELECT_OBJECTS_DICT = yaml.safe_load("""903actions:904- Select-object:905 Type: Enterprise906 By-field: name907 Value: test_enterprise908 Actions:909 - Select-object:910 Type: DomainTemplate911 By-field: test_field_1912 Value: test_value_1913 - Select-object:914 Type: Domain915 By-field: test_field_2916 Value: test_value_2917- select-object:918 type: Enterprise919 By-field: name920 Value: test_enterprise_2921 actions:922 - select-object:923 type: DomainTemplate924 by-field: test_field_3925 value: test_value_3926 - select-object:927 type: Domain928 by-field: test_field_4929 value: test_value_4930""")931SELECT_OBJECTS_MULTIPLE = yaml.safe_load("""932actions:933- Select-object:934 type: Enterprise935 by-field:936 - name937 - count938 value:939 - enterprise1940 - 5941""")942SELECT_OBJECTS_MULTIPLE_BAD_TYPE = yaml.safe_load("""943actions:944- Select-object:945 type: Enterprise946 by-field:947 - name948 value: 5949""")950SELECT_OBJECTS_MULTIPLE_WITH_SINGLE = yaml.safe_load("""951actions:952- Select-object:953 type: Enterprise954 by-field:955 - name956 value:957 - enterprise1958""")959SELECT_OBJECTS_MULTIPLE_MISMATCH = yaml.safe_load("""960actions:961- Select-object:962 type: Enterprise963 by-field:964 - name965 - count966 value:967 - enterprise1968 - 5969 - extra970""")971SELECT_OBJECTS_NO_FIELD = yaml.safe_load("""972actions:973- Select-object:974 type: Enterprise975 by-field: null976 value: value977""")978SELECT_OBJECTS_NO_TYPE = yaml.safe_load("""979actions:980- Select-object:981 Missing-type: Invalid982 by-field: name983 value: value984""")985SELECT_OBJECTS_NO_VALUE = yaml.safe_load("""986actions:987- Select-object:988 type: Enterprise989 by-field: name990 missing-value: Invalid991""")992SELECT_RETRIEVE_MISSING_RETRIEVE = yaml.safe_load("""993actions:994- Select-object:995 By-field: name996 Type: Object1997 Value: value_1998 Actions:999 - Store-value:1000 As-name: object_id1001 From-field: objectId1002- Select-object:1003 By-field: $retrieve-value1004 Type: Object21005 Value: WRONG_VALUE1006 Actions:1007 - Retrieve-value:1008 From-name: object_id1009 To-field: id1010 - Create-object:1011 Type: Level21012 Actions:1013 - Set-values:1014 name: L2-O11015""")1016SELECT_RETRIEVE_NOT_RETRIEVE = yaml.safe_load("""1017actions:1018- Select-object:1019 Type: Object11020 By-field: name1021 Value: value_11022 Actions:1023 - Store-value:1024 As-name: object_id1025 From-field: objectId1026- Select-object:1027 Type: Object21028 By-field: $retrieve-value1029 Value: id1030 Actions:1031 - Set-values:1032 id: NOT_RETRIEVE1033 - Create-object:1034 Type: Level21035 Actions:1036 - Set-values:1037 name: L2-O11038""")1039SELECT_RETRIEVE_VALUE = yaml.safe_load("""1040actions:1041- Select-object:1042 Type: Object11043 By-field: name1044 Value: value_11045 Actions:1046 - Store-value:1047 As-name: object_id1048 From-field: objectId1049- Select-object:1050 Type: Object21051 By-field: $retrieve-value1052 Value: id1053 Actions:1054 - Retrieve-value:1055 From-name: object_id1056 To-field: id1057 - Create-object:1058 Type: Level21059 Actions:1060 - Set-values:1061 name: L2-O11062""")1063CREATE_FIELD_RETRIEVE_VALUE = yaml.safe_load("""1064actions:1065- Create-object:1066 Type: Object11067 Actions:1068 - Set-values:1069 name: L1-O11070 - Create-object:1071 Type: Object21072 Value: value_11073 Actions:1074 - Set-values:1075 name: other_name1076 - Store-value:1077 As-name: object_id1078 From-field: objectId1079- Create-object:1080 Type: Object31081 Select-By-field: other_id1082 Actions:1083 - Retrieve-value:1084 From-name: object_id1085 To-field: other_id1086 - Create-object:1087 Type: Level21088 Actions:1089 - Set-values:1090 name: L2-O11091""")1092SET_VALUES_DICT = yaml.safe_load("""1093actions:1094- Create-object:1095 Type: Enterprise1096 Select-by-field: field11097 Actions:1098 - Create-object:1099 Type: DomainTemplate1100 - Set-values:1101 field1: value11102 field2: true1103 - Create-object:1104 Type: Domain1105 - Set-values:1106 field3: null1107 field4: 41108""")1109SET_VALUES_CONFLICT = yaml.safe_load("""1110actions:1111- Create-object:1112 Type: Enterprise1113 Actions:1114 - Set-values:1115 field1: value11116 field2: true1117 - Set-values:1118 field2: false1119 field4: 41120""")1121SET_VALUES_NO_OBJECT = yaml.safe_load("""1122actions:1123- Set-values:1124 field1: value11125 field2: true1126""")1127STORE_NO_FIELD = yaml.safe_load("""1128actions:1129- Create-object:1130 Type: Enterprise1131 Actions:1132 - Create-object:1133 Type: DomainTemplate1134 Actions:1135 - Store-value:1136 As-name: template_id1137 Missing-from-field: Invalid1138""")1139STORE_NO_OBJECT = yaml.safe_load("""1140actions:1141- Store-value:1142 as-name: template_id1143 from-field: id1144""")1145STORE_NO_NAME = yaml.safe_load("""1146actions:1147- Create-object:1148 Type: Enterprise1149 Actions:1150 - Create-object:1151 Type: DomainTemplate1152 Actions:1153 - Store-value:1154 As-name: null1155 from-field: id1156""")1157STORE_RETRIEVE_DICT = yaml.safe_load("""1158actions:1159- Create-object:1160 Type: Enterprise1161 Actions:1162 - Set-values:1163 name: enterprise11164 - Create-object:1165 Type: DomainTemplate1166 Actions:1167 - Store-value:1168 As-name: template_id1169 from-field: id1170 - Set-values:1171 name: domain_template1172 - create-object:1173 type: Domain1174 actions:1175 - Set-values:1176 name: domain11177 - Retrieve-value:1178 From-name: template_id1179 To-field: templateID1180 - create-object:1181 type: Domain1182 actions:1183 - retrieve-value:1184 from-name: template_id1185 to-field: templateID1186 - set-values:1187 name: domain21188""")1189STORE_SAME_TWICE = yaml.safe_load("""1190actions:1191- Create-object:1192 Type: Enterprise1193 Actions:1194 - create-object:1195 type: DomainTemplate1196 actions:1197 - Set-values:1198 name: domain11199 - Store-value:1200 As-name: template_id1201 from-field: id1202 - Create-object:1203 Type: Domain1204 Actions:1205 - Store-value:1206 As-name: template_id1207 from-field: templateID1208 - Set-values:1209 name: domain_template1210""")1211STORE_RETRIEVE_TO_OBJECT = yaml.safe_load("""1212actions:1213- Create-object:1214 Type: Enterprise1215 Actions:1216 - Set-values:1217 name: enterprise11218 - Create-object:1219 Type: NSGatewayTemplate1220 Actions:1221 - Store-value:1222 As-name: template_id1223 from-field: id1224 - Set-values:1225 name: nsg_template1226 - create-object:1227 type: Job1228 actions:1229 - Set-values:1230 parameters:1231 type: ISO1232 - Retrieve-value:1233 From-name: template_id1234 To-field: parameters.entityID1235""")1236STORE_RETRIEVE_TO_OBJECT_NOT_SET = yaml.safe_load("""1237actions:1238- Create-object:1239 Type: Enterprise1240 Actions:1241 - Set-values:1242 name: enterprise11243 - Create-object:1244 Type: NSGatewayTemplate1245 Actions:1246 - Store-value:1247 As-name: template_id1248 from-field: id1249 - Set-values:1250 name: nsg_template1251 - create-object:1252 type: Job1253 actions:1254 - Set-values:1255 wrongName:1256 type: ISO1257 - Retrieve-value:1258 From-name: template_id1259 To-field: parameters.entityID1260""")1261STORE_RETRIEVE_TO_OBJECT_NOT_DICT = yaml.safe_load("""1262actions:1263- Create-object:1264 Type: Enterprise1265 Actions:1266 - Set-values:1267 name: enterprise11268 - Create-object:1269 Type: NSGatewayTemplate1270 Actions:1271 - Store-value:1272 As-name: template_id1273 from-field: id1274 - Set-values:1275 name: nsg_template1276 - create-object:1277 type: Job1278 actions:1279 - Set-values:1280 parameters: not a dictionary1281 - Retrieve-value:1282 From-name: template_id1283 To-field: parameters.entityID1284""")1285STORE_RETRIEVE_TO_OBJECT_ALREADY_SET = yaml.safe_load("""1286actions:1287- Create-object:1288 Type: Enterprise1289 Actions:1290 - Set-values:1291 name: enterprise11292 - Create-object:1293 Type: NSGatewayTemplate1294 Actions:1295 - Store-value:1296 As-name: template_id1297 from-field: id1298 - Set-values:1299 name: nsg_template1300 - create-object:1301 type: Job1302 actions:1303 - Set-values:1304 parameters:1305 type: ISO1306 entityID: already set1307 - Retrieve-value:1308 From-name: template_id1309 To-field: parameters.entityID1310""")1311SET_VALUES_FIELD_SAME_VALUE = yaml.safe_load("""1312actions:1313- Create-object:1314 Type: Enterprise1315 Actions:1316 - Set-values:1317 name: enterprise11318 - Create-object:1319 Type: Infrastructure Access Profile1320 Actions:1321 - Set-values:1322 name: access11323 ssh_key_names: ["key1"]1324 ssh_keys: ["japudofiuasdfoiudpfou"]1325 - Select-object:1326 Type: Infrastructure Access Profile1327 By-field: name1328 Value: access11329 Actions:1330 - Set-values:1331 name: access11332 ssh_key_names: ["key1"]1333 ssh_keys: ["japudofiuasdfoiudpfou"]1334""")1335SET_VALUES_FIELD_DIFFERENT_VALUE = yaml.safe_load("""1336actions:1337- Create-object:1338 Type: Enterprise1339 Actions:1340 - Set-values:1341 name: enterprise11342 - Create-object:1343 Type: Infrastructure Access Profile1344 Actions:1345 - Set-values:1346 name: access11347 ssh_key_names: ["key1"]1348 ssh_keys: ["japudofiuasdfoiudpfou"]1349 - Select-object:1350 Type: Infrastructure Access Profile1351 By-field: name1352 Value: access11353 Actions:1354 - Set-values:1355 name: access11356 ssh_key_names: ["key2"]1357 ssh_keys: ["japudofiuasdfoiudpfou"]1358""")1359SAVE_TO_FILE = yaml.safe_load("""1360actions:1361- Create-object:1362 Type: Job1363 Actions:1364 - set-values:1365 command: GET_ZFB_INFO1366 parameters:1367 mediaType: ISO1368 - Save-to-file:1369 File-path: /tmp/pytest_save_to_file.txt1370 Append-to-file: false1371 From-field: result1372 Write-to-console: True1373""")1374SAVE_TO_FILE_AND_CONSOLE = yaml.safe_load("""1375actions:1376- Create-object:1377 Type: Job1378 Actions:1379 - set-values:1380 command: GET_ZFB_INFO1381 parameters:1382 mediaType: ISO1383 - Save-to-file:1384 File-path: /tmp/pytest_save_to_file.txt1385 Append-to-file: false1386 From-field: result1387 Write-to-console: true1388""")1389SAVE_TO_FILE_NO_FILE = yaml.safe_load("""1390actions:1391- Create-object:1392 Type: Job1393 Actions:1394 - set-values:1395 command: GET_ZFB_INFO1396 parameters:1397 mediaType: ISO1398 - Save-to-file:1399 Append-to-file: false1400 From-field: result1401""")1402SAVE_TO_FILE_APPEND = yaml.safe_load("""1403actions:1404- Create-object:1405 Type: Job1406 Actions:1407 - set-values:1408 command: GET_ZFB_INFO1409 parameters:1410 mediaType: ISO1411 - Save-to-file:1412 File-path: /tmp/pytest_save_to_file.txt1413 Prefix-string: "no:"1414 Suffix-string: ":value"1415 - Save-to-file:1416 File-path: /tmp/pytest_save_to_file.txt1417 Append-to-file: true1418 Prefix-string: "prefix:"1419 From-field: result1420 Suffix-string: ":suffix"1421 Write-to-console: False1422""")1423SAVE_TO_FILE_DECODE = yaml.safe_load("""1424actions:1425- Create-object:1426 Type: Job1427 Actions:1428 - set-values:1429 command: GET_ZFB_INFO1430 parameters:1431 mediaType: ISO1432 - Save-to-file:1433 File-path: /tmp/pytest_save_to_file.txt1434 Prefix-string: "no:"1435 Suffix-string: ":value"1436 - Save-to-file:1437 File-path: /tmp/pytest_save_to_file.txt1438 Append-to-file: true1439 Prefix-string: "prefix:"1440 From-field: result1441 Suffix-string: ":suffix"1442 Write-to-console: False1443 decode: base641444""")1445UPDATE_ROOT_OBJECT = yaml.safe_load("""1446actions:1447- Create-object:1448 Type: Level11449 Actions:1450 - Set-values:1451 name: L1-O11452""")1453UPDATE_ROOT_UPDATE_NOT_SUPPORTED_OBJECT = yaml.safe_load("""1454actions:1455- Create-object:1456 Type: Level11457 update-supported: False1458 Actions:1459 - Set-values:1460 name: L1-O11461 - store-value:1462 as-name: level1_id1463 from-field: id1464""")1465UPDATE_CHILD_OBJECT_WITH_FIRST_SELECTOR = yaml.safe_load("""1466actions:1467- Create-object:1468 Type: Level11469 update-supported: False1470 Actions:1471 - Set-values:1472 name: L1-O11473 - Create-object:1474 type: Level21475 select-by-field: $first1476 Actions:1477 - Set-values:1478 value: L21479""")1480UPDATE_CHILD_OBJECT_WITH_LAST_SELECTOR = yaml.safe_load("""1481actions:1482- Create-object:1483 Type: Level11484 update-supported: False1485 Actions:1486 - Set-values:1487 name: L1-O11488 - Create-object:1489 type: Level21490 select-by-field: $last1491 Actions:1492 - Set-values:1493 value: L21494""")1495UPDATE_SELECT_ROOT_OBJECT = yaml.safe_load("""1496actions:1497- Select-object:1498 Type: Level11499 by-field: name1500 value: L1-011501 Actions:1502 - Set-values:1503 name: L1-O11504 - store-value:1505 as-name: level1_id1506 from-field: id1507""")1508UPDATE_CREATE_CHILD_OBJECT = yaml.safe_load("""1509actions:1510- Create-object:1511 Type: Level11512 Actions:1513 - Set-values:1514 name: L1-O11515 - Create-object:1516 Type: Level21517 Actions:1518 - Set-values:1519 name: L2-O1...

Full Screen

Full Screen

test_yaml_validation.py

Source:test_yaml_validation.py Github

copy

Full Screen

...10 yaml_input = """11 %s12 """ % i13 with pytest.raises(ValueError):14 YamlValidation.validate(yaml.safe_load(yaml_input))15def test_yaml_valasp_in_user_defined_module():16 yaml_input = """17 having:18 equals:19 - [first, second]20 - [first2, second]21 different:22 - [first, second]23 - [first2, second]24 gt:25 - [first, second]26 - [first2, second]27 ge:28 - [first, second]29 - [first2, second]30 lt:31 - [first, second]32 - [first2, second]33 le:34 - [first, second]35 - [first2, second]36 validate_predicate: True37 with_fun: FORWARD_IMPLICIT38 auto_blacklist: True39 after_init: |+40 code41 to42 add43 at44 the45 end46 of47 __post_init__48 before_grounding: |+49 cls.instances = set()50 after_grounding: |+51 if len(cls.instances()) < 10:52 raise ...53 """54 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))55def test_yaml_valasp_in_user_defined_module():56 yaml_input = """57 valasp:58 having:59 - first == second60 - first2 != second61 - first3 < second62 - first3 <= second63 - first3 > second64 - first3 >= second65 - first == second66 - first==second 67 - first >=second68 - first>=second 69 validate_predicate: True 70 """71 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))72def test_yaml_valasp_in_user_defined_module_2():73 for i in {"Integer", "String", "Alpha", "Any"}:74 for oper in {"==", "!=", ">", ">=", "<", "<=", " == ", " !=", "> ", " >=", "< ", " <= "}:75 yaml_input = """76 predicate:77 first: %s78 second: %s79 valasp:80 having:81 - first%ssecond 82 """ % (i, i, oper)83 YamlValidation.validate(yaml.safe_load(yaml_input))84def test_yaml_having_valasp_in_user_defined_module_wrong_keyword():85 for i in {'different', '<>', '=', '>>'}:86 yaml_input = """87 having:88 - first %s second 89 """ % i90 with pytest.raises(ValueError):91 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))92def test_yaml_having_valasp_in_user_defined_module_wrong_name():93 for i in {'>', '==', '!=', '<='}:94 yaml_input = """95 having:96 - First %s second 97 """ % i98 with pytest.raises(ValueError):99 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))100 for i in {'>', '==', '!=', '<='}:101 yaml_input = """102 having:103 - first %s Second 104 """ % i105 with pytest.raises(ValueError):106 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))107def test_yaml_having_valasp_not_a_list():108 for i in [10, '1', {'first': 0}]:109 yaml_input = """110 having: %s 111 """ % i112 with pytest.raises(ValueError):113 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))114def test_yaml_having_valasp_in_user_defined_module_not_a_list():115 yaml_input = """116 having: 117 different: Integer 118 """119 with pytest.raises(ValueError):120 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))121def test_yaml_having_valasp_in_user_defined_module_not_valid_split():122 for i in ['first == second == third', ['a', 'b'], 'first of == second']:123 yaml_input = """124 having:125 - %s126 """ % i127 with pytest.raises(ValueError):128 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))129def test_yaml_having_valasp_in_user_defined_module_complex_usage():130 yaml_input = """131 having:132 equals:133 - [first, second, third]134 - [first2, second]135 different:136 - [first, second]137 - [first2, second]138 """139 with pytest.raises(ValueError):140 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))141def test_yaml_having_valasp_in_user_defined_module_missing_list():142 yaml_input = """143 having:144 equals: 145 different:146 - [first, second]147 - [first2, second]148 """149 with pytest.raises(ValueError):150 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))151def test_yaml_validate_predicate_correct_bool():152 for i in {'True', 'true', 'TRUE'}:153 yaml_input = """154 validate_predicate: %s155 """ % i156 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))157def test_yaml_validate_predicate_not_bool():158 for i in [0, 1, {'dict': 0}]:159 yaml_input = """160 validate_predicate: %s161 """ % i162 with pytest.raises(ValueError):163 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))164def test_yaml_validate_predicate_mispelled_true():165 for i in {'TRue', 'TrUE', 'TruE', 'trUe', 'truE'}:166 yaml_input = """167 validate_predicate: %s168 """ % i169 with pytest.raises(ValueError):170 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))171def test_yaml_with_fun_correct():172 for i in {'FORWARD_IMPLICIT', 'FORWARD', 'IMPLICIT', 'TUPLE'}:173 yaml_input = """174 with_fun: %s175 """ % i176 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))177def test_yaml_with_fun_wrong_keyword():178 for i in {'FORWARDIMPLICIT', 'WOW', 'forward', 'Implicit', '_TUPLE'}:179 yaml_input = """180 with_fun: %s181 """ % i182 with pytest.raises(ValueError):183 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))184def test_yaml_auto_blacklist_correct_bool():185 for i in {'False', 'false', 'FALSE'}:186 yaml_input = """187 auto_blacklist: %s188 """ % i189 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))190def test_yaml_auto_blacklist_not_bool():191 for i in [0, 1, {'dict': 0}]:192 yaml_input = """193 auto_blacklist: %s194 """ % i195 with pytest.raises(ValueError):196 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))197def test_yaml_auto_blacklist_mispelled_false():198 for i in {'falSe', 'FAlse', 'FaLSE', 'FalsE', 'falsE'}:199 yaml_input = """200 validate_predicate: %s201 """ % i202 with pytest.raises(ValueError):203 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))204def test_yaml_after_init():205 yaml_input = """206 after_init: |+207 code to add at the end of __post_init__208 """209 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))210def test_yaml_after_init_wrong_type():211 yaml_input = """212 after_init: [1,2,3] 213 """214 with pytest.raises(ValueError):215 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))216def test_yaml_before_grounding():217 yaml_input = """218 before_grounding: |+219 code to execute after grounding220 """221 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))222def test_yaml_before_grounding_wrong_type():223 yaml_input = """224 before_grounding: [1,2,3] 225 """226 with pytest.raises(ValueError):227 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))228def test_yaml_after_grounding():229 yaml_input = """230 after_grounding: |+231 code to execute after grounding232 """233 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))234def test_yaml_after_grounding_wrong_type():235 yaml_input = """236 after_grounding: [1,2,3] 237 """238 with pytest.raises(ValueError):239 YamlValidation.validate_valasp_in_symbol(yaml.safe_load(yaml_input))240def test_yaml_valasp():241 yaml_input = """242 python: |+243 for i in range(10):244 print(i)245 asp: |+246 code247 248 wrap:249 - a250 - B251 - lower252 - Upper253 254 max_arity: 10255 """256 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))257def test_yaml_valasp_max_arity_wrong_types():258 for i in ['a', -1, 100, {'a': 1}, [1]]:259 yaml_input = """260 max_arity: %s261 """ % i262 with pytest.raises(ValueError):263 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))264def test_yaml_valasp_wrap_not_list():265 for i in ['a', 1, {'a': 1}]:266 yaml_input = """ 267 wrap: %s 268 """ % i269 with pytest.raises(ValueError):270 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))271def test_yaml_valasp_not_predicate():272 yaml_input = """ 273 wrap:274 - a a 275 """276 with pytest.raises(ValueError):277 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))278def test_yaml_valasp_root():279 yaml_input = """280 valasp:281 python: |+282 for i in range(10):283 print(i)284 asp: |+285 code286 """287 YamlValidation.validate(yaml.safe_load(yaml_input))288def test_yaml_valasp_wrong_keyword():289 yaml_input = """290 python: |+291 for i in range(10):292 print(i)293 ASP: |+294 code295 """296 with pytest.raises(ValueError):297 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))298def test_yaml_valasp_asp_wrong_type():299 yaml_input = """300 python: |+301 for i in range(10):302 print(i)303 asp:304 something:305 here306 """307 with pytest.raises(ValueError):308 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))309def test_yaml_valasp_python_wrong_type():310 yaml_input = """311 python:312 - something313 - here314 asp: |+315 a(X) :- b(X).316 """317 with pytest.raises(ValueError):318 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))319def test_yaml_valasp_python_wrong_type():320 yaml_input = """321 python:322 - something323 - here324 asp: |+325 a(X) :- b(X).326 """327 with pytest.raises(ValueError):328 YamlValidation.validate_valasp(yaml.safe_load(yaml_input))329def test_yaml_symbol_name():330 for i in {'predicate', '_predicate', '_preDicate', '___predicate', '"on"', '"off"'}:331 yaml_input = """332 %s:333 term1: Integer334 """ % i335 YamlValidation.validate(yaml.safe_load(yaml_input))336def test_yaml_symbol_name_invalid_names():337 for i in ['Name', 'Valasp', 'valasp', 'on', 'off', 1, -2, '"1"', "_Predicate"]:338 yaml_input = f"""339 {i}:340 term1: Integer341 """342 with pytest.raises(ValueError):343 YamlValidation.validate(yaml.safe_load(yaml_input))344 for i in [['name'], {'name'}]:345 yaml_input = f"""346 {i}:347 term1: Integer348 """349 with pytest.raises(ConstructorError):350 yaml.safe_load(yaml_input)351def test_yaml_symbol_name_not_a_dictionary():352 for i in ['Integer', 'String', 'pred', ['a', 'b']]:353 yaml_input = """354 predicate: %s 355 """ % i356 with pytest.raises(ValueError):357 YamlValidation.validate(yaml.safe_load(yaml_input))358def test_yaml_term_type_declaration():359 for i in {'Integer', 'String', 'Alpha', 'Any', 'predicate', '_predicate', '_preDicate', '___predicate', '"on"', '"off"'}:360 yaml_input = """361 term1: %s362 """ % i363 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))364def test_yaml_term_invalid_term_types():365 for i in ['Name', 'Valasp', 'on', 'off', 1, -2, ['name'], '"1"', "_Predicate"]:366 yaml_input = """367 term1: %s368 """ % i369 with pytest.raises(ValueError):370 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))371def test_yaml_term_integer_declaration():372 yaml_input = """373 term_name_6:374 type: Integer375 min: 0376 max: 99377 sum+:378 min: 0379 max: 1000380 sum-:381 min: -1000382 max: -10383 count:384 min: 10385 max: 100386 sum+: Integer387 enum: [1, 2, 3]388 """389 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))390def test_yaml_term_integer_min_greater_than_max():391 yaml_input = """392 term_name_6:393 type: Integer394 min: 20395 max: 10 396 """397 with pytest.raises(ValueError):398 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))399def test_yaml_term_integer_declaration_no_type():400 yaml_input = """401 term_name_6:402 min: 0403 max: 99404 sum+:405 min: 0406 max: 1000407 sum-:408 min: 0409 max: -1000410 count:411 min: 10412 max: 100413 sum+: Integer414 enum: [1, 2, 3]415 """416 with pytest.raises(ValueError):417 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))418def test_yaml_term_integer_declaration_wrong_keyword():419 for j in {'Integer', 'String'}:420 for i in {'MIN', 'minimum'}:421 yaml_input = """422 term_name_6:423 type: %s424 %s: 0425 """ % (j, i)426 with pytest.raises(ValueError):427 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))428def test_yaml_term_integer_declaration_invalid_min():429 for j in {'Integer', 'String'}:430 for i in {1000000000000, 'Integer'}:431 yaml_input = """432 term_name_6:433 type: %s434 min: %s 435 """ % (j, i)436 with pytest.raises(ValueError):437 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))438def test_yaml_term_integer_declaration_invalid_max():439 for i in {1000000000000, 'Integer'}:440 yaml_input = """441 term_name_6:442 type: Integer443 max: %s 444 """ % i445 with pytest.raises(ValueError):446 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))447def test_yaml_term_integer_declaration_invalid_enum_integer():448 for i in [['1', 2, 3], 1, {'value': 0}]:449 yaml_input = """450 term_name_6:451 type: Integer452 enum: %s453 """ % i454 with pytest.raises(ValueError):455 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))456def test_yaml_term_integer_declaration_invalid_sum_positive():457 for i in {'String', 'int', 10}:458 yaml_input = """459 term_name_6:460 type: Integer461 sum+: %s 462 """ % i463 with pytest.raises(ValueError):464 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))465 for i in {100000000000, 'Integer', -5}:466 yaml_input = """467 term_name_6:468 type: Integer469 sum+:470 min: 0471 max: %s 472 """ % i473 with pytest.raises(ValueError):474 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))475 for i in {100000000000, 'Integer', -5}:476 yaml_input = """477 term_name_6:478 type: Integer479 sum+:480 min: %s481 max: 10 482 """ % i483 with pytest.raises(ValueError):484 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))485def test_yaml_term_integer_declaration_invalid_sum_negative():486 for i in {'String', 'int', -10}:487 yaml_input = """488 term_name_6:489 type: Integer490 sum-: %s 491 """ % i492 with pytest.raises(ValueError):493 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))494 for i in {-10000000000, 'Integer', 10}:495 yaml_input = """496 term_name_6:497 type: Integer498 sum-:499 min: 0500 max: %s 501 """ % i502 with pytest.raises(ValueError):503 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))504 for i in {-10000000000, 'Integer', 10}:505 yaml_input = """506 term_name_6:507 type: Integer508 sum-:509 min: %s510 max: 0 511 """ % i512 with pytest.raises(ValueError):513 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))514def test_yaml_term_declaration_invalid_count():515 for j in {'Integer', 'String', 'Any', 'Alpha', 'user_defined'}:516 for i in {-5, 100000000000, 'Integer'}:517 yaml_input = """518 term_name_6:519 type: %s520 count:521 min: %s522 max: 0 523 """ % (j, i)524 with pytest.raises(ValueError):525 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))526 for i in {-5, 100000000000, 'Integer'}:527 yaml_input = """528 term_name_6:529 type: %s530 count:531 min: 0532 max: %s 533 """ % (j, i)534 with pytest.raises(ValueError):535 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))536def test_yaml_term_elements_invalid_declaration():537 for j in {'String', 'Any', 'Alpha', 'user_defined'}:538 for i in {'sum+', 'sum-'}:539 yaml_input = """540 term_name_6:541 type: %s542 %s:543 min: 0544 max: 1000545 """ % (j, i)546 with pytest.raises(ValueError):547 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))548def test_yaml_term_string_enum():549 yaml_input = """550 term_name_6:551 type: String552 enum: ['1', '2', '3', 'ok test']553 """554 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))555def test_yaml_term_string_invalid_enum():556 yaml_input = """557 term_name_6:558 type: String559 enum: [1, 'my logic', 'wow']560 """561 with pytest.raises(ValueError):562 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))563def test_yaml_term_alpha_enum():564 yaml_input = """565 term_name_6:566 type: Alpha567 enum: [logic1, my_logic, well]568 """569 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))570def test_yaml_term_alpha_invalid_enum():571 yaml_input = """572 term_name_6:573 type: Alpha574 enum: [logic1, 'my logic', well]575 """576 with pytest.raises(ValueError):577 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))578def test_yaml_term_alpha_invalid_min():579 for s in {'String', 'Alpha'}:580 for i in [-1, 'a', [1, 2]]:581 yaml_input = """582 term_name_6:583 type: %s584 min: %s585 """ % (s, i)586 with pytest.raises(ValueError):587 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))588def test_yaml_term_pattern():589 for i in {'String', 'Alpha'}:590 yaml_input = """591 term_name_6:592 type: %s593 pattern: '(a | b)'594 """ % i595 YamlValidation.validate_symbol(yaml.safe_load(yaml_input))596def test_yaml_term_invalid_pattern():597 for i in {'String', 'Alpha'}:598 yaml_input = """599 term_name_6:600 type: %s601 pattern: '(a | b'602 """ % i603 with pytest.raises(ValueError):...

Full Screen

Full Screen

over_view.py

Source:over_view.py Github

copy

Full Screen

...29 # y_a = pd.DataFrame(django_search_query(coke_drum_yields_actual_values))30 # y_p = pd.DataFrame(django_search_query(coke_drum_yields_predicted_values))31 # if parameter == 'Coke Drum':32 # result = {33 # "actual_values": yaml.safe_load(34 # a.to_json(orient='records')),35 # "predicted_values": yaml.safe_load(36 # p.to_json(orient='records')),37 # "yields_actual_values": yaml.safe_load(y_a.to_json(orient='records')),38 # "yields_predicted_values": yaml.safe_load(39 # y_p.to_json(orient='records'))40 # }41 # if parameter == 'input Feed':42 # a = pd.DataFrame(django_search_query(feed_actual_values))43 # p = pd.DataFrame(django_search_query(feed_predicted_values.format(version=version)))44 # y_a = pd.DataFrame(django_search_query(feed_yields_actual_values))45 # y_p = pd.DataFrame(django_search_query(feed_yields_predicted_values))46 # if parameter == 'input Feed':47 # result = {48 # "actual_values": yaml.safe_load(49 # a.to_json(orient='records')),50 # "predicted_values": yaml.safe_load(51 # p.to_json(orient='records')),52 # "yields_actual_values": yaml.safe_load(y_a.to_json(orient='records')),53 # "yields_predicted_values": yaml.safe_load(54 # y_p.to_json(orient='records'))55 # }56 # if parameter == 'Heater':57 # a = pd.DataFrame(django_search_query(heater_actual_values))58 # p = pd.DataFrame(django_search_query(heater_predicted_values.format(version=version)))59 # y_a = pd.DataFrame(django_search_query(heater_yields_actual_values))60 # y_p = pd.DataFrame(django_search_query(heater_yields_predicted_values))61 # if parameter == 'Heater':62 # result = {63 # "actual_values": yaml.safe_load(64 # a.to_json(orient='records')),65 # "predicted_values": yaml.safe_load(66 # p.to_json(orient='records')),67 # "yields_actual_values": yaml.safe_load(y_a.to_json(orient='records')),68 # "yields_predicted_values": yaml.safe_load(69 # y_p.to_json(orient='records'))70 # }71 # if parameter == 'Fractionator':72 # a = pd.DataFrame(django_search_query(fractinator_actual_values))73 # p = pd.DataFrame(django_search_query(fractinator_predicted_values.format(version=version)))74 # y_a = pd.DataFrame(django_search_query(fractinator_yields_actual_values))75 # y_p = pd.DataFrame(django_search_query(fractinator_yields_predicted_values))76 # if parameter == 'Fractionator':77 # result = {78 # "actual_values": yaml.safe_load(79 # a.to_json(orient='records')),80 # "predicted_values": yaml.safe_load(81 # p.to_json(orient='records')),82 # "yields_actual_values": yaml.safe_load(y_a.to_json(orient='records')),83 # "yields_predicted_values": yaml.safe_load(84 # y_p.to_json(orient='records'))85 # }86 # final_result.append(result)87 # result["Coke Drum"] = {}88 # result["input Feed"] = {}89 # result["Heater"] = {}90 # result["Fractionator"] = {}91 # result["yields"] = {}92 #93 # """ Getting Coke Drum Data """94 # try:95 # a = pd.DataFrame(django_search_query(coke_drum_actual_values.format(version=version)))96 # p = pd.DataFrame(django_search_query(coke_drum_predicted_values.format(version=version)))97 # if not a.empty:98 # result["Coke Drum"]["actual_values"] = yaml.safe_load(99 # a.to_json(orient='records'))100 # else:101 # result["Coke Drum"]["actual_values"] = yaml.safe_load(102 # a.to_json(orient='records'))103 # if not p.empty:104 # result["Coke Drum"]["predicted_values"] = yaml.safe_load(105 # p.to_json(orient='records'))106 # else:107 # result["Coke Drum"]["predicted_values"] = yaml.safe_load(108 # p.to_json(orient='records'))109 # except Exception as err:110 # return response_exception(err)111 #112 # """ Getting input Feed Data """113 #114 # try:115 # a = pd.DataFrame(django_search_query(feed_actual_values.format(version=version)))116 # p = pd.DataFrame(django_search_query(feed_predicted_values.format(version=version)))117 # if not a.empty:118 # result["input Feed"]["actual_values"] = yaml.safe_load(119 # a.to_json(orient='records'))120 # else:121 # result["input Feed"]["actual_values"] = yaml.safe_load(122 # a.to_json(orient='records'))123 # if not p.empty:124 # result["input Feed"]["predicted_values"] = yaml.safe_load(125 # p.to_json(orient='records'))126 # else:127 # result["input Feed"]["predicted_values"] = yaml.safe_load(128 # p.to_json(orient='records'))129 #130 # except Exception as err:131 # return response_exception(err)132 #133 # """ Getting Heater Data """134 #135 # try:136 # a = pd.DataFrame(django_search_query(heater_actual_values.format(version=version)))137 # p = pd.DataFrame(django_search_query(heater_predicted_values.format(version=version)))138 # if not a.empty:139 # result["Heater"]["actual_values"] = yaml.safe_load(140 # a.to_json(orient='records'))141 # else:142 # result["Heater"]["actual_values"] = yaml.safe_load(143 # a.to_json(orient='records'))144 # if not p.empty:145 # result["Heater"]["predicted_values"] = yaml.safe_load(146 # p.to_json(orient='records'))147 # else:148 # result["Heater"]["predicted_values"] = yaml.safe_load(149 # p.to_json(orient='records'))150 #151 # except Exception as err:152 # return response_exception(err)153 #154 # """ Getting Fractionator Data """155 #156 # try:157 # a = pd.DataFrame(django_search_query(fractinator_actual_values.format(version=version)))158 # p = pd.DataFrame(django_search_query(fractinator_predicted_values.format(version=version)))159 # if not a.empty:160 # result["Fractionator"]["actual_values"] = yaml.safe_load(161 # a.to_json(orient='records'))162 # else:163 # result["Fractionator"]["actual_values"] = yaml.safe_load(164 # a.to_json(orient='records'))165 # if not p.empty:166 # result["Fractionator"]["predicted_values"] = yaml.safe_load(167 # p.to_json(orient='records'))168 # else:169 # result["Fractionator"]["predicted_values"] = yaml.safe_load(170 # p.to_json(orient='records'))171 #172 # except Exception as err:173 # return response_exception(err)174 #175 # """ Getting yields Data """176 #177 # try:178 # a = pd.DataFrame(django_search_query(dcu_yields_actual_values.format(version=version)))179 # p = pd.DataFrame(django_search_query(dcu_yields_predicted_values.format(version=version)))180 # if not a.empty:181 # result["yields"]["yields_actual_values"] = yaml.safe_load(182 # a.to_json(orient='records'))183 # else:184 # result["yields"]["yields_actual_values"] = yaml.safe_load(185 # a.to_json(orient='records'))186 # if not p.empty:187 # result["yields"]["yields_predicted_values"] = yaml.safe_load(188 # p.to_json(orient='records'))189 # else:190 # result["yields"]["yields_predicted_values"] = yaml.safe_load(191 # p.to_json(orient='records'))192 result["Coke Drum"] = {}193 result["input Feed"] = {}194 result["Heater"] = {}195 result["Fractionator"] = {}196 result["yields"] = {}197 """ Getting Coke Drum Data """198 try:199 timestamp = pd.DataFrame(django_search_query("""select max(timestamp) from parameter_input"""))200 if not timestamp.empty:201 result['timestamp'] = timestamp['max'].iloc[0]202 else:203 result['timestamp'] = None204 a = pd.DataFrame(django_search_query(coke_actual_values))205 p = pd.DataFrame(django_search_query(coke_predicted_values))206 if not a.empty:207 result["Coke Drum"]["actual_values"] = yaml.safe_load(208 a.to_json(orient='records'))209 else:210 result["Coke Drum"]["actual_values"] = yaml.safe_load(211 a.to_json(orient='records'))212 if not p.empty:213 result["Coke Drum"]["predicted_values"] = yaml.safe_load(214 p.to_json(orient='records'))215 else:216 result["Coke Drum"]["predicted_values"] = yaml.safe_load(217 p.to_json(orient='records'))218 except Exception as err:219 return response_exception(err)220 """ Getting input Feed Data """221 try:222 a = pd.DataFrame(django_search_query(input_feed_data))223 p = pd.DataFrame(django_search_query(input_feed_pred_data))224 if not a.empty:225 result["input Feed"]["actual_values"] = yaml.safe_load(226 a.to_json(orient='records'))227 else:228 result["input Feed"]["actual_values"] = yaml.safe_load(229 a.to_json(orient='records'))230 if not p.empty:231 result["input Feed"]["predicted_values"] = yaml.safe_load(232 p.to_json(orient='records'))233 else:234 result["input Feed"]["predicted_values"] = yaml.safe_load(235 p.to_json(orient='records'))236 except Exception as err:237 return response_exception(err)238 """ Getting Heater Data """239 try:240 a = pd.DataFrame(django_search_query(heater_actual_data_values))241 p = pd.DataFrame(django_search_query(heater_pred_data_values))242 if not a.empty:243 result["Heater"]["actual_values"] = yaml.safe_load(244 a.to_json(orient='records'))245 else:246 result["Heater"]["actual_values"] = yaml.safe_load(247 a.to_json(orient='records'))248 if not p.empty:249 result["Heater"]["predicted_values"] = yaml.safe_load(250 p.to_json(orient='records'))251 else:252 result["Heater"]["predicted_values"] = yaml.safe_load(253 p.to_json(orient='records'))254 except Exception as err:255 return response_exception(err)256 """ Getting Fractionator Data """257 try:258 a = pd.DataFrame(django_search_query(fractinator_actual_data_values))259 p = pd.DataFrame(django_search_query(fractinator_pred_data_values))260 if not a.empty:261 result["Fractionator"]["actual_values"] = yaml.safe_load(262 a.to_json(orient='records'))263 else:264 result["Fractionator"]["actual_values"] = yaml.safe_load(265 a.to_json(orient='records'))266 if not p.empty:267 result["Fractionator"]["predicted_values"] = yaml.safe_load(268 p.to_json(orient='records'))269 else:270 result["Fractionator"]["predicted_values"] = yaml.safe_load(271 p.to_json(orient='records'))272 except Exception as err:273 return response_exception(err)274 """ Getting yields Data """275 try:276 a = pd.DataFrame(django_search_query(dcu_yields_actual_data_values))277 p = pd.DataFrame(django_search_query(dcu_yields_result_data))278 if not a.empty:279 result["yields"]["yields_actual_values"] = yaml.safe_load(280 a.to_json(orient='records'))281 else:282 result["yields"]["yields_actual_values"] = yaml.safe_load(283 a.to_json(orient='records'))284 if not p.empty:285 result["yields"]["yields_predicted_values"] = yaml.safe_load(286 p.to_json(orient='records'))287 else:288 result["yields"]["yields_predicted_values"] = yaml.safe_load(289 p.to_json(orient='records'))290 except Exception as err:291 return response_exception(err)292 final_result.append(result)293 return response_success(data=final_result)294 except Exception as err:295 return response_exception(err)296 else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful