Pārlūkot izejas kodu

Add simple test for the Modelverse wrapper in Python

Yentl Van Tendeloo 8 gadi atpakaļ
vecāks
revīzija
30bb85cf01
3 mainītis faili ar 12 papildinājumiem un 5 dzēšanām
  1. 2 2
      core/mini_modify.alc
  2. 6 3
      wrappers/modelverse.py
  3. 4 0
      wrappers/test_modelverse.py

+ 2 - 2
core/mini_modify.alc

@@ -262,7 +262,7 @@ Element function modify(model : Element, write : Boolean):
 			if (dict_in(model["model"], cmd)):
 				String t
 				output("Type of outgoing edge (empty for all)?")
-				elems = readOutgoingAssociationInstances(model, cmd, input())
+				elems = allOutgoingAssociationInstances(model, cmd, input())
 				while (read_nr_out(elems) > 0):
 					output(set_pop(elems))
 			else:
@@ -275,7 +275,7 @@ Element function modify(model : Element, write : Boolean):
 			if (dict_in(model["model"], cmd)):
 				String t
 				output("Type of incoming edge (empty for all)?")
-				elems = readIncomingAssociationInstances(model, cmd, input())
+				elems = allIncomingAssociationInstances(model, cmd, input())
 				while (read_nr_out(elems) > 0):
 					output(set_pop(elems))
 			else:

+ 6 - 3
wrappers/modelverse.py

@@ -1,11 +1,12 @@
 import urllib
 import urllib2
 import json
+import random
 from urllib2 import URLError
 
 # Helper functions and configuration: do not use yourself!
-taskname = "test"
-address = "http://localhost:8001"
+taskname = random.random()
+address = None
 last_output = None
 mode = 0
 
@@ -72,7 +73,7 @@ class InvalidMode(Exception):
     pass
 
 # Main MvC operations
-def init():
+def init(address_param="http://localhost:8001"):
     """Starts up the connection to the Modelverse."""
     # return None
     # raises ConnectionError
@@ -81,6 +82,8 @@ def init():
     global mode
     if mode != 0:
         raise InvalidMode()
+    global address
+    address = address_param
     try:
         _input_raw('"%s"' % taskname, "user_manager")
         mode = 1

+ 4 - 0
wrappers/test_modelverse.py

@@ -0,0 +1,4 @@
+from modelverse import *
+
+init()
+register("user1", "password")