Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor incremental tests #434

Merged
merged 8 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lona/client2/_lona/client2/rendering-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export class LonaRenderingEngine {
_render_node(node_spec) {
const node_type = node_spec[0];

// TODO: remove in 2.0
if(!(node_type == Lona.protocol.NODE_TYPE.NODE ||
node_type == Lona.protocol.NODE_TYPE.TEXT_NODE)) {

throw(`unsupported node type: ${node_type}`);
};

// TextNode
if(node_type == Lona.protocol.NODE_TYPE.TEXT_NODE) {
const node_id = node_spec[1];
Expand Down
5 changes: 5 additions & 0 deletions lona/html/abstract_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def __eq__(self, other):
if self.NODE_TYPE == NODE_TYPE.TEXT_NODE:
return self._string == other._string

# widgets
# TODO: remove in 2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe issue a deprecation warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until now we did not issue deprecation warnings but added wrote them to the documentation. It's a good idea to deprecate the Legacy Widget API now, but I think it's a little bit much for this PR because the old API gets used in multiple examples in the documentation. I opened #437 as a base for a follow-up PR.

if self.NODE_TYPE == NODE_TYPE.WIDGET:
return (self.nodes == other.nodes and
self.data == other.data)
# nodes
if other.namespace != self.namespace:
return False
Expand Down
8 changes: 7 additions & 1 deletion lona/html/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Node(AbstractNode):
ATTRIBUTES: dict[str, str] = {}
EVENTS: list[EventType | ChangeEventType] = []
WIDGET: str = ''
WIDGET_DATA: dict | list = {}

def __init__(
self,
Expand All @@ -51,6 +52,7 @@ def __init__(
tag_name=None,
self_closing_tag=None,
widget='',
widget_data=None,
**kwargs,
):

Expand All @@ -61,7 +63,11 @@ def __init__(
self._nodes = NodeList(self)
self._events = NodeEventList(self, self.EVENTS)
self._widget = widget or self.WIDGET
self._widget_data = WidgetData(widget=self)

self._widget_data = WidgetData(
widget=self,
value=widget_data or self.WIDGET_DATA,
)

# tag overrides
self._namespace = namespace or self.NAMESPACE
Expand Down
6 changes: 5 additions & 1 deletion lona/html/node_list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections.abc import Iterable

from lona.html.abstract_node import AbstractNode
from lona.protocol import PATCH_TYPE, OPERATION
from lona.html.text_node import TextNode
Expand Down Expand Up @@ -218,7 +220,9 @@ def __contains__(self, node):
def _reset(self, values):
self._assert_not_frozen()

if not isinstance(values, list):
if (isinstance(values, AbstractNode) or
not isinstance(values, Iterable)):

values = [values]

with self._node.lock:
Expand Down
4 changes: 2 additions & 2 deletions lona/html/widget_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ def __eq__(self, other):


class WidgetData:
def __init__(self, widget):
def __init__(self, widget, value=None):
self._widget = widget

self._reset({}, initial=True)
self._reset(value or {}, initial=True)

def __getitem__(self, *args, **kwargs):
return self._overlay.__getitem__(*args, **kwargs)
Expand Down
5 changes: 2 additions & 3 deletions lona/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@
HttpRedirectResponse,
TemplateResponse,
RedirectResponse,
JsonResponse,
HtmlResponse,
)
from lona.compat import set_use_future_node_classes, set_client_version
from lona.view_runtime_controller import ViewRuntimeController
from lona.responses import FileResponse as LonaFileResponse
from lona.responses import AbstractResponse as LonaResponse
from lona.middleware_controller import MiddlewareController
from lona.responses import JsonResponse, HtmlResponse
from lona.static_file_loader import StaticFileLoader
from lona.responses import Response as LonaResponse
from lona.templating import TemplatingEngine
from lona.imports import acquire as _acquire
from lona.worker_pool import WorkerPool
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ test = [
"coverage==7.2.7",
"pytest==7.4.0",
"pytest-aiohttp==1.0.4",
"pytest-dependency==0.5.1",
"pytest-mock==3.11.1",
"pytest-timeout==2.1.0",
"playwright==1.35.0",
Expand Down
5 changes: 1 addition & 4 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[pytest]
addopts= tests -v -rsx --tb=long --strict-markers
markers =
incremental: marks test class to stop execution after the first test method failed
addopts= tests -v -x -rsx --tb=long --strict-markers
log_cli= false
log_level= NOTSET
log_format = %(levelname)-8s %(name)-30s [%(asctime)s.%(msecs)03d] %(message)s
log_date_format = %H:%M:%S
automark_dependency = True
timeout = 300
asyncio_mode = auto
57 changes: 0 additions & 57 deletions tests/conftest.py

This file was deleted.

Loading