Ejemplo n.º 1
0
 def test_set_new_document(self):
     old_doc = get_document()
     doc = get_new_document()
     self.assertIsNot(doc, old_doc)
     set_document(doc)
     new_doc = get_document()
     self.assertIsNot(doc, old_doc)
     self.assertIs(doc, new_doc)
Ejemplo n.º 2
0
 def test_set_new_document(self):
     old_doc = get_document()
     doc = get_new_document()
     self.assertIsNot(doc, old_doc)
     set_document(doc)
     new_doc = get_document()
     self.assertIsNot(doc, old_doc)
     self.assertIs(doc, new_doc)
Ejemplo n.º 3
0
def reset() -> None:
    """Reset all wdom objects.

    This function clear all connections, elements, and resistered custom
    elements. This function also makes new document/application and set them.
    """
    from wdom.document import get_new_document, set_document
    from wdom.element import Element
    from wdom.server import _tornado
    from wdom.window import customElements

    set_document(get_new_document())
    _tornado.connections.clear()
    _tornado.set_application(_tornado.Application())
    Element._elements_with_id.clear()
    Element._element_buffer.clear()
    customElements.reset()
Ejemplo n.º 4
0
def reset():
    """Reset all wdom objects.

    This function clear all connections, elements, and resistered custom
    elements. This function also makes new document/application and set them.
    """
    from wdom.document import get_new_document, set_document

    set_document(get_new_document())
    from wdom.server import _tornado

    _tornado.connections.clear()
    _tornado.set_application(_tornado.Application())
    try:
        from wdom.server import _aiohttp

        _aiohttp.connections.clear()
        _aiohttp.set_application(_aiohttp.Application())
    except ImportError:
        pass
    Element._elements_with_id.clear()
    Element._elements.clear()
    customElements.clear()
Ejemplo n.º 5
0
 def test_document_reload_wait(self):
     doc = get_new_document(autoreload=True, reload_wait=1234)
     html = doc.build()
     self.assertIn('RIMO_AUTORELOAD = true', html)
     self.assertIn('RIMO_RELOAD_WAIT = 1234', html)
Ejemplo n.º 6
0
 def test_document_autoreload(self):
     doc = get_new_document(autoreload=True)
     html = doc.build()
     self.assertIn('RIMO_AUTORELOAD = true', html)
     self.assertNotIn('RIMO_RELOAD_WAIT', html)
Ejemplo n.º 7
0
 def tearDown(self):
     stop_server(self.server)
     set_document(get_new_document())
     sync(self.page.goto('about:blank'))
     time.sleep(0.1)
Ejemplo n.º 8
0
 def test_document_log_console(self):
     doc = get_new_document(log_console=True)
     html = doc.build()
     self.assertIn('RIMO_LOG_CONSOLE = true', html)
Ejemplo n.º 9
0
 def test_document_log_level_int(self):
     doc = get_new_document(log_level=10)
     html = doc.build()
     self.assertIn('RIMO_LOG_LEVEL = 10', html)
Ejemplo n.º 10
0
 def test_document_log_level_int(self):
     doc = get_new_document(log_level=10)
     html = doc.build()
     self.assertIn('WDOM_LOG_LEVEL = 10', html)
Ejemplo n.º 11
0
 def test_document_log_level_str(self):
     doc = get_new_document(log_level='INFO')
     html = doc.build()
     self.assertIn('WDOM_LOG_LEVEL = \'INFO\'', html)
Ejemplo n.º 12
0
 def test_document_no_reload_wait_no_reload(self):
     doc = get_new_document(autoreload=False, reload_wait=1234)
     html = doc.build()
     self.assertNotIn('WDOM_AUTORELOAD', html)
     self.assertNotIn('WDOM_RELOAD_WAIT', html)
Ejemplo n.º 13
0
 def test_document_reload_wait(self):
     doc = get_new_document(autoreload=True, reload_wait=1234)
     html = doc.build()
     self.assertIn('WDOM_AUTORELOAD = true', html)
     self.assertIn('WDOM_RELOAD_WAIT = 1234', html)
Ejemplo n.º 14
0
 def test_document_autoreload(self):
     doc = get_new_document(autoreload=True)
     html = doc.build()
     self.assertIn('WDOM_AUTORELOAD = true', html)
     self.assertNotIn('WDOM_RELOAD_WAIT', html)
Ejemplo n.º 15
0
 def test_document_no_reload_wait_no_reload(self):
     doc = get_new_document(autoreload=False, reload_wait=1234)
     html = doc.build()
     self.assertNotIn('RIMO_AUTORELOAD', html)
     self.assertNotIn('RIMO_RELOAD_WAIT', html)
Ejemplo n.º 16
0
 def test_document_log_level_str(self):
     doc = get_new_document(log_level='INFO')
     html = doc.build()
     self.assertIn('RIMO_LOG_LEVEL = \'INFO\'', html)
Ejemplo n.º 17
0
 def test_document_log_prefix(self):
     doc = get_new_document(log_prefix='TEST')
     html = doc.build()
     self.assertIn('WDOM_LOG_PREFIX = \'TEST\'', html)
Ejemplo n.º 18
0
 def test_document_log_prefix(self):
     doc = get_new_document(log_prefix='TEST')
     html = doc.build()
     self.assertIn('RIMO_LOG_PREFIX = \'TEST\'', html)
Ejemplo n.º 19
0
 def test_document_log_console(self):
     doc = get_new_document(log_console=True)
     html = doc.build()
     self.assertIn('WDOM_LOG_CONSOLE = true', html)
Ejemplo n.º 20
0
 def test_document_ws_url(self):
     doc = get_new_document(ws_url='test_ws')
     html = doc.build()
     self.assertIn('RIMO_WS_URL = \'test_ws\'', html)
Ejemplo n.º 21
0
 def test_document_ws_url(self):
     doc = get_new_document(ws_url='test_ws')
     html = doc.build()
     self.assertIn('WDOM_WS_URL = \'test_ws\'', html)