Browse Source

Add randomizing test script

Pete Shadbolt 1 year ago
parent
commit
9f0b46c7dc
2 changed files with 33 additions and 3 deletions
  1. 28
    0
      randomize.py
  2. 5
    3
      test.py

+ 28
- 0
randomize.py View File

@@ -0,0 +1,28 @@
1
+"""
2
+Makes a dummy post to the test server
3
+"""
4
+import requests
5
+import json
6
+import abp
7
+import random
8
+import time
9
+
10
+#URL = "http://localhost:5000"
11
+URL = "https://abv.peteshadbolt.co.uk/"
12
+
13
+def test_graph():
14
+    N = 50
15
+    g = abp.NXGraphState(range(N))
16
+
17
+    for i in range(N):
18
+        g.act_cz(random.randint(0, N-1), random.randint(0, N-1))
19
+
20
+    g.layout()
21
+    return g
22
+
23
+if __name__ == '__main__':
24
+    while True:
25
+        data = json.dumps(test_graph().to_json(stringify=False))
26
+        r = requests.post("{}/graph".format(URL), data=data)
27
+        time.sleep(5)
28
+

+ 5
- 3
test.py View File

@@ -4,16 +4,18 @@ Makes a dummy post to the test server
4 4
 import requests
5 5
 import json
6 6
 import abp
7
+import random
7 8
 
8 9
 #URL = "http://localhost:5000"
9 10
 URL = "https://abv.peteshadbolt.co.uk/"
10 11
 
11 12
 def test_graph():
12
-    N = 100
13
+    N = 50
13 14
     g = abp.NXGraphState(range(N))
14 15
 
15
-    for i in range(N-1):
16
-        g.act_cz(i, i+1)
16
+    for i in range(N):
17
+        g.act_cz(random.randint(0, N-1), random.randint(0, N-1))
18
+
17 19
     g.layout()
18 20
     return g
19 21