test_mvc.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. import unittest
  2. from utils import run_file, get_constructor, get_raw_model_constructor
  3. all_files = [ "core/mini_modify.alc",
  4. "core/core_formalism.mvc",
  5. "core/core_algorithm.alc",
  6. "primitives.alc",
  7. "object_operations.alc",
  8. "conformance_scd.alc",
  9. "library.alc",
  10. "ftg.alc",
  11. "transform.alc",
  12. "model_management.alc",
  13. "ramify.alc",
  14. "metamodels.alc",
  15. "random.alc",
  16. "constructors.alc",
  17. "modelling.alc",
  18. "compilation_manager.alc",
  19. ]
  20. class TestModelverseCore(unittest.TestCase):
  21. def test_po_list(self):
  22. self.list("PO")
  23. def list(self, mode):
  24. self.assertTrue(run_file(all_files,
  25. [ "root",
  26. "model_list",
  27. ],
  28. [ "Desired username for admin user?",
  29. "Welcome to the Model Management Interface v2.0!",
  30. "Use the 'help' command for a list of possible commands",
  31. "Ready for command...",
  32. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  33. " CoreFormalism : SimpleClassDiagrams",
  34. " core : CoreFormalism"]),
  35. ],
  36. mode))
  37. def test_po_list_full(self):
  38. self.list_full("PO")
  39. def list_full(self, mode):
  40. self.assertTrue(run_file(all_files,
  41. [ "root",
  42. "model_list_full",
  43. ],
  44. [ "Desired username for admin user?",
  45. "Welcome to the Model Management Interface v2.0!",
  46. "Use the 'help' command for a list of possible commands",
  47. "Ready for command...",
  48. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  49. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  50. " 200 root admin 43 core : CoreFormalism"]),
  51. ],
  52. mode))
  53. def test_po_model_add_empty(self):
  54. self.model_add_empty("PO")
  55. def model_add_empty(self, mode):
  56. self.assertTrue(run_file(all_files,
  57. [ "root",
  58. "model_add",
  59. "SimpleClassDiagrams",
  60. "Empty",
  61. "exit",
  62. "model_list",
  63. "model_list_full",
  64. ],
  65. [ "Desired username for admin user?",
  66. "Welcome to the Model Management Interface v2.0!",
  67. "Use the 'help' command for a list of possible commands",
  68. "Ready for command...",
  69. "Creating new model!",
  70. "Model type?",
  71. "Model name?",
  72. "Waiting for model constructors...",
  73. "Model upload success!",
  74. "Ready for command...",
  75. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  76. " CoreFormalism : SimpleClassDiagrams",
  77. " Empty : SimpleClassDiagrams",
  78. " core : CoreFormalism"]),
  79. "Ready for command...",
  80. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  81. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  82. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  83. " 200 root admin 53 core : CoreFormalism"]),
  84. ],
  85. mode))
  86. def test_po_model_empty_modify(self):
  87. self.model_empty_modify("PO")
  88. def model_empty_modify(self, mode):
  89. self.assertTrue(run_file(all_files,
  90. [ "root",
  91. "model_add",
  92. "SimpleClassDiagrams",
  93. "Empty",
  94. "exit",
  95. "model_list",
  96. "model_list_full",
  97. "model_modify",
  98. "Empty",
  99. "instantiate",
  100. "Class",
  101. "A",
  102. "exit",
  103. "model_list_full",
  104. ],
  105. [ "Desired username for admin user?",
  106. "Welcome to the Model Management Interface v2.0!",
  107. "Use the 'help' command for a list of possible commands",
  108. "Ready for command...",
  109. "Creating new model!",
  110. "Model type?",
  111. "Model name?",
  112. "Waiting for model constructors...",
  113. "Model upload success!",
  114. "Ready for command...",
  115. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  116. " CoreFormalism : SimpleClassDiagrams",
  117. " Empty : SimpleClassDiagrams",
  118. " core : CoreFormalism"]),
  119. "Ready for command...",
  120. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  121. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  122. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  123. " 200 root admin 53 core : CoreFormalism"]),
  124. "Ready for command...",
  125. "Which model do you want to modify?",
  126. "Model loaded, ready for commands!",
  127. "Use 'help' command for a list of possible commands",
  128. "Please give your command.",
  129. "Type to instantiate?",
  130. "Name of new element?",
  131. "Instantiation successful!",
  132. "Please give your command.",
  133. "Ready for command...",
  134. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  135. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  136. " 200 root nobody 1 Empty : SimpleClassDiagrams",
  137. " 200 root admin 53 core : CoreFormalism"]),
  138. "Ready for command...",
  139. ],
  140. mode))
  141. def test_po_model_overwrite(self):
  142. self.model_overwrite("PO")
  143. def model_overwrite(self, mode):
  144. self.assertTrue(run_file(all_files,
  145. [ "root",
  146. "model_add",
  147. "SimpleClassDiagrams",
  148. "Empty",
  149. "exit",
  150. "model_list_full",
  151. "model_modify",
  152. "Empty",
  153. "instantiate",
  154. "Class",
  155. "A",
  156. "exit",
  157. "model_list_full",
  158. "model_overwrite",
  159. "Empty",
  160. "instantiate_node",
  161. "Class",
  162. "B",
  163. "instantiate_node",
  164. "Class",
  165. "C",
  166. "exit",
  167. "model_list_full",
  168. "model_modify",
  169. "Empty",
  170. "list",
  171. "exit",
  172. ],
  173. [ "Desired username for admin user?",
  174. "Welcome to the Model Management Interface v2.0!",
  175. "Use the 'help' command for a list of possible commands",
  176. "Ready for command...",
  177. "Creating new model!",
  178. "Model type?",
  179. "Model name?",
  180. "Waiting for model constructors...",
  181. "Model upload success!",
  182. "Ready for command...",
  183. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  184. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  185. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  186. " 200 root admin 53 core : CoreFormalism"]),
  187. "Ready for command...",
  188. "Which model do you want to modify?",
  189. "Model loaded, ready for commands!",
  190. "Use 'help' command for a list of possible commands",
  191. "Please give your command.",
  192. "Type to instantiate?",
  193. "Name of new element?",
  194. "Instantiation successful!",
  195. "Please give your command.",
  196. "Ready for command...",
  197. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  198. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  199. " 200 root nobody 1 Empty : SimpleClassDiagrams",
  200. " 200 root admin 53 core : CoreFormalism"]),
  201. "Ready for command...",
  202. "Which model to overwrite?",
  203. "Waiting for model constructors...",
  204. "Model overwrite success!",
  205. "Ready for command...",
  206. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  207. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  208. " 200 root nobody 2 Empty : SimpleClassDiagrams",
  209. " 200 root admin 53 core : CoreFormalism"]),
  210. "Ready for command...",
  211. "Which model do you want to modify?",
  212. "Model loaded, ready for commands!",
  213. "Use 'help' command for a list of possible commands",
  214. "Please give your command.",
  215. "List of all elements:",
  216. set([" B : Class",
  217. " C : Class"]),
  218. "Please give your command.",
  219. "Ready for command...",
  220. ],
  221. mode))
  222. def test_po_transform_add_MT_language(self):
  223. self.transform_add_MT_language("PO")
  224. def transform_add_MT_language(self, mode):
  225. self.assertTrue(run_file(all_files,
  226. [ "root",
  227. "model_add",
  228. "SimpleClassDiagrams",
  229. "PetriNets",
  230. ] + get_raw_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
  231. "model_list_full",
  232. "transformation_add_MT_language",
  233. "PetriNets",
  234. "",
  235. "PetriNets_RAM",
  236. "model_list_full",
  237. ],
  238. [ "Desired username for admin user?",
  239. "Welcome to the Model Management Interface v2.0!",
  240. "Use the 'help' command for a list of possible commands",
  241. "Ready for command...",
  242. "Creating new model!",
  243. "Model type?",
  244. "Model name?",
  245. "Waiting for model constructors...",
  246. "Model upload success!",
  247. "Ready for command...",
  248. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  249. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  250. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  251. " 200 root admin 53 core : CoreFormalism"]),
  252. "Ready for command...",
  253. "Formalisms to include (terminate with empty string)?",
  254. "Name of the RAMified transformation metamodel?",
  255. "Ready for command...",
  256. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  257. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  258. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  259. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  260. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  261. " 200 root admin 76 core : CoreFormalism"]),
  262. "Ready for command...",
  263. ],
  264. mode))
  265. def test_po_transform_add_MT_instance(self):
  266. self.transform_add_MT_instance("PO")
  267. def transform_add_MT_instance(self, mode):
  268. self.assertTrue(run_file(all_files,
  269. [ "root",
  270. "model_add",
  271. "SimpleClassDiagrams",
  272. "PetriNets",
  273. ] + get_raw_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
  274. "model_list_full",
  275. "transformation_add_MT_language",
  276. "PetriNets",
  277. "",
  278. "PetriNets_RAM",
  279. "model_list_full",
  280. "transformation_add_MT",
  281. "PetriNets_RAM",
  282. "PetriNets",
  283. ],
  284. [ "Desired username for admin user?",
  285. "Welcome to the Model Management Interface v2.0!",
  286. "Use the 'help' command for a list of possible commands",
  287. "Ready for command...",
  288. "Creating new model!",
  289. "Model type?",
  290. "Model name?",
  291. "Waiting for model constructors...",
  292. "Model upload success!",
  293. "Ready for command...",
  294. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  295. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  296. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  297. " 200 root admin 53 core : CoreFormalism"]),
  298. "Ready for command...",
  299. "Formalisms to include (terminate with empty string)?",
  300. "Name of the RAMified transformation metamodel?",
  301. "Ready for command...",
  302. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  303. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  304. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  305. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  306. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  307. " 200 root admin 79 core : CoreFormalism"]),
  308. "Ready for command...",
  309. "RAMified metamodel to use?",
  310. "Supported metamodels:",
  311. set([" PetriNets",
  312. ]),
  313. "",
  314. "Which ones do you want to use as source (empty string to finish)?",
  315. "Model added as source",
  316. "Which ones do you want to use as target (empty string to finish)?",
  317. "Model added as target",
  318. "Name of new transformation?",
  319. "Met-info correctly set!",
  320. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  321. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  322. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  323. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  324. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  325. " 200 root admin 79 core : CoreFormalism"]),
  326. "Ready for command...",
  327. "Merged metamodel to RAMify again?",
  328. "Ready for command...",
  329. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  330. " 221 root admin 86 CoreFormalism : SimpleClassDiagrams",
  331. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  332. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  333. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  334. " 200 root admin 79 core : CoreFormalism"]),
  335. "Ready for command...",
  336. ],
  337. mode))