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)
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()
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()
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)
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)
def tearDown(self): stop_server(self.server) set_document(get_new_document()) sync(self.page.goto('about:blank')) time.sleep(0.1)
def test_document_log_console(self): doc = get_new_document(log_console=True) html = doc.build() self.assertIn('RIMO_LOG_CONSOLE = true', html)
def test_document_log_level_int(self): doc = get_new_document(log_level=10) html = doc.build() self.assertIn('RIMO_LOG_LEVEL = 10', html)
def test_document_log_level_int(self): doc = get_new_document(log_level=10) html = doc.build() self.assertIn('WDOM_LOG_LEVEL = 10', html)
def test_document_log_level_str(self): doc = get_new_document(log_level='INFO') html = doc.build() self.assertIn('WDOM_LOG_LEVEL = \'INFO\'', html)
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)
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)
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)
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)
def test_document_log_level_str(self): doc = get_new_document(log_level='INFO') html = doc.build() self.assertIn('RIMO_LOG_LEVEL = \'INFO\'', html)
def test_document_log_prefix(self): doc = get_new_document(log_prefix='TEST') html = doc.build() self.assertIn('WDOM_LOG_PREFIX = \'TEST\'', html)
def test_document_log_prefix(self): doc = get_new_document(log_prefix='TEST') html = doc.build() self.assertIn('RIMO_LOG_PREFIX = \'TEST\'', html)
def test_document_log_console(self): doc = get_new_document(log_console=True) html = doc.build() self.assertIn('WDOM_LOG_CONSOLE = true', html)
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)
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)