test_mvc.py 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import unittest
  2. from utils import run_file, get_constructor, get_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))