Browse Source

test: update

wangweimin 4 years ago
parent
commit
886e92eac8
4 changed files with 41 additions and 10 deletions
  1. 1 1
      test/11.charts.py
  2. 35 5
      test/13.misc.py
  3. 1 1
      test/16.path_deploy.py
  4. 4 3
      test/template.py

+ 1 - 1
test/11.charts.py

@@ -375,7 +375,7 @@ def target():
 
 
 def test(server_proc: subprocess.Popen, browser: Chrome):
-    time.sleep(6)
+    time.sleep(15)
     percySnapshot(browser, name='bokeh')
 
 

+ 35 - 5
test/13.misc.py

@@ -120,7 +120,34 @@ def target():
     with use_scope('error'):
         put_buttons(['Raise error'], [lambda: 1 / 0])
 
-    put_text('\n' * 40)
+    put_image('/static/favicon_open_32.png')
+
+    with put_info():
+        put_table([
+            ['Commodity', 'Price'],
+            ['Apple', '5.5'],
+            ['Banana', '7'],
+        ])
+        put_markdown('~~Strikethrough~~')
+        put_file('hello_word.txt', b'hello word!')
+
+    with put_collapse('title', open=True):
+        put_table([
+            ['Commodity', 'Price'],
+            ['Apple', '5.5'],
+            ['Banana', '7'],
+        ])
+
+        with put_collapse('title', open=True):
+            put_table([
+                ['Commodity', 'Price'],
+                ['Apple', '5.5'],
+                ['Banana', '7'],
+            ])
+
+        put_markdown('~~Strikethrough~~')
+        put_file('hello_word.txt', b'hello word!')
+
     yield input_group('test input popup', [
         input('username', name='user'),
         actions('', ['Login', 'Register', 'Forget'], name='action')
@@ -151,7 +178,6 @@ def threadbased():
 
 def test(server_proc: subprocess.Popen, browser: Chrome):
     time.sleep(2)
-    percySnapshot(browser, name='misc output')
 
     coro_out = template.save_output(browser)[-1]
 
@@ -164,18 +190,22 @@ def test(server_proc: subprocess.Popen, browser: Chrome):
 
     assert "ToastClicked" in coro_out
     assert coro_out == thread_out
+    browser.execute_script("WebIO._state.CurrentSession.ws.close()")
+    time.sleep(6)
 
     browser.execute_script("arguments[0].click();",
                            browser.find_element_by_css_selector('#pywebio-scope-error button'))
     browser.execute_script("$('button[type=submit]').click();")
     time.sleep(2)
-    browser.get('http://localhost:8080/')
-    time.sleep(2)
+    percySnapshot(browser, name='misc')
+
 
 
 def start_test_server():
     pywebio.enable_debug()
-    start_server([corobased, partial(threadbased)], port=8080, host='127.0.0.1', debug=True, cdn=False)
+
+    start_server([corobased, partial(threadbased)], port=8080, host='127.0.0.1', debug=True, cdn=False,
+                 static_dir=STATIC_PATH + '/image', reconnect_timeout=10)
 
 
 if __name__ == '__main__':

+ 1 - 1
test/16.path_deploy.py

@@ -10,7 +10,7 @@ from pywebio.utils import *
 
 
 def test(server_proc: subprocess.Popen, browser: Chrome):
-    time.sleep(6)
+    time.sleep(10)
     percySnapshot(browser, name='path_deploy_1')
     time.sleep(2)
     browser.get('http://localhost:8080/')

+ 4 - 3
test/template.py

@@ -105,7 +105,7 @@ def basic_output():
         ['Type', 'Content'],
         ['text', '<hr/>'],
         ['html', put_html('X<sup>2</sup>')],
-        ['buttons', put_buttons(['A', 'B'], onclick=None, small=True)],
+        ['buttons', put_buttons(['A', 'B'], onclick=put_text, small=True)],
         ['markdown', put_markdown('`awesome PyWebIO!`\n - 1\n - 2\n - 3')],
         ['file', put_file('hello.text', b'')],
         ['image', put_image(img_data)],
@@ -135,7 +135,7 @@ def basic_output():
                 ['Type', 'Content'],
                 ['html', put_html('X<sup>2</sup>')],
                 ['text', '<hr/>'],
-                ['buttons', put_buttons(['A', 'B'], onclick=...)],
+                ['buttons', put_buttons(['A', 'B'], onclick=put_text)],
                 ['markdown', put_markdown('`Awesome PyWebIO!`')],
                 ['file', put_file('hello.text', b'')],
                 ['table', put_table([['A', 'B'], ['C', 'D']])]
@@ -201,7 +201,8 @@ def basic_output():
     remove('to_remove')
 
     put_markdown('### Info')
-    session_info = get_info()
+    from pywebio import session
+    session_info = session.info
     from django.http import HttpRequest
     from flask import Request
     from tornado.httputil import HTTPServerRequest