-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issues and erros fixed , missing import issues and redundant imports …
…fixed
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# from django.urls import reverse | ||
# from django import forms | ||
# import pytest | ||
|
||
# from dashboards.component.filters import Filter | ||
# from dashboards.forms import DashboardForm | ||
# from tests.utils import render_component_test | ||
|
||
# pytest_plugins = [ | ||
# "tests.dashboards.fixtures", | ||
# ] | ||
|
||
# class TestFilter(DashboardForm): | ||
# filter_field = forms.CharField() | ||
|
||
# @pytest.mark.parametrize("htmx", [True, False]) | ||
# def test_filter_component__renders_value(dashboard, htmx, rf, snapshot): | ||
# form_instance = TestFilter() # Create an instance of the form | ||
# component = Filter(form=form_instance, model=None, method="get") | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
|
||
# # Ensure that the Filter component is added to the dashboard's components | ||
# dashboard.components = [component] | ||
|
||
# context = Context( | ||
# { | ||
# "component": component, | ||
# "request": rf.get("/"), | ||
# } | ||
# ) | ||
|
||
# snapshot.assert_match(render_component_test(context, htmx=htmx)) | ||
# @pytest.mark.parametrize("method", ["get", "post"]) | ||
# def test_filter_component__get_value(dashboard, method, rf): | ||
# component = Filter(form=TestFilter, model=None, method=method, dependents=["component_1"]) | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
# request = rf.get("/") | ||
# value = component.get_value(request) | ||
|
||
# assert isinstance(value["form"], TestFilter) | ||
# assert value["method"] == method | ||
# assert value["dependents"] == ["component_1"] | ||
# assert value["action"] == component.get_submit_url() | ||
|
||
# def test_filter_component__get_submit_url(dashboard): | ||
# component = Filter(form=TestFilter, model=None) | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
|
||
# assert component.get_submit_url() == reverse( | ||
# "dashboards:filter_component", | ||
# args=[dashboard._meta.app_label, dashboard.class_name(), "test"], | ||
# ) | ||
|
||
# def test_filter_component__get_submit_url__specified(dashboard): | ||
# component = Filter(form=TestFilter, model=None, submit_url="/submit-me/") | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
|
||
# assert component.get_submit_url() == "/submit-me/" | ||
|
||
# def test_filter_component__get_form_with_get(dashboard, rf): | ||
# component = Filter(form=TestFilter, model=None, method="get") | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
# request = rf.get("/?filter_field=value") | ||
# form = component.get_form(request) | ||
|
||
# assert isinstance(form, TestFilter) | ||
|
||
# def test_filter_component__get_form_with_post(dashboard, rf): | ||
# component = Filter(form=TestFilter, model=None, method="post") | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
# request = rf.post("/", {"filter_field": "value"}) | ||
|
||
# form = component.get_form(request) | ||
|
||
# assert isinstance(form, TestFilter) | ||
|
||
# def test_filter_component__get_value_returns_error_on_invalid(dashboard, rf): | ||
# component = Filter(form=TestFilter, model=None, method="get") | ||
# component.dashboard = dashboard | ||
# component.key = "test" | ||
# request = rf.post("/", {}) | ||
# form = component.get_form(request) | ||
|
||
# assert form.errors == {"filter_field": ["This field is required."]} |