-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for remaining tethys_component reactpy files Adds reactpy-django to standard install Fixes broken support for variable in url for pages Adds react-loading-overlay and react-map-gl to built-in ComponentLibrary support Fixes buggy use_workspace
- Loading branch information
1 parent
b6178b8
commit 9122f42
Showing
16 changed files
with
203 additions
and
42 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 |
---|---|---|
|
@@ -104,3 +104,7 @@ dependencies: | |
- factory_boy | ||
- flake8 | ||
- flake8-bugbear | ||
|
||
# reactpy dependencies | ||
- pip: | ||
- reactpy-django |
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
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
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,84 @@ | ||
from tethys_components import custom | ||
from tethys_components.library import Library as lib | ||
from unittest import TestCase, mock, IsolatedAsyncioTestCase | ||
from importlib import reload | ||
import asyncio | ||
|
||
|
||
class TestCustomComponents(IsolatedAsyncioTestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
mock.patch('reactpy.component', new_callable=lambda: lambda x: x).start() | ||
reload(custom) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
mock.patch.stopall() | ||
reload(custom) | ||
lib.refresh() | ||
|
||
def test_Panel_defaults(self): | ||
test_component = custom.Panel({}) | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('attributes', test_component) | ||
self.assertIn('children', test_component) | ||
|
||
async def test_Panel_all_props_provided(self): | ||
test_set_show = mock.MagicMock() | ||
props = { | ||
"show": True, | ||
"set-show": test_set_show, | ||
"position": "right", | ||
"extent": "30vw", | ||
"name": "Test Panel 123" | ||
} | ||
test_component = custom.Panel(props) | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('attributes', test_component) | ||
self.assertIn('children', test_component) | ||
test_set_show.assert_not_called() | ||
event_handler = test_component['children'][0]['children'][1]['eventHandlers']['on_click'] | ||
self.assertTrue(callable(event_handler.function)) | ||
await event_handler.function([None]) | ||
test_set_show.assert_called_once_with(False) | ||
|
||
def test_HeaderButton(self): | ||
test_component = custom.HeaderButton({}) | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('attributes', test_component) | ||
|
||
def test_NavIcon(self): | ||
test_component = custom.NavIcon('test_src', 'test_color') | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('attributes', test_component) | ||
|
||
def test_NavMenu(self): | ||
test_component = custom.NavMenu({}) | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('children', test_component) | ||
|
||
def test_HeaderWithNavBar(self): | ||
custom.lib.hooks = mock.MagicMock() | ||
custom.lib.hooks.use_query().data.id = 10 | ||
test_app = mock.MagicMock(icon="icon.png", color="test_color") | ||
test_user = mock.MagicMock() | ||
test_nav_links = [mock.MagicMock(), mock.MagicMock(), mock.MagicMock()] | ||
test_component = custom.HeaderWithNavBar(test_app, test_user, test_nav_links) | ||
self.assertIsInstance(test_component, dict) | ||
self.assertIn('tagName', test_component) | ||
self.assertIn('attributes', test_component) | ||
self.assertIn('children', test_component) | ||
del custom.lib.hooks | ||
|
||
def test_get_db_object(self): | ||
test_app = mock.MagicMock() | ||
return_val = custom.get_db_object(test_app) | ||
self.assertEqual(return_val, test_app.db_object) | ||
|
||
def test_hooks(self): | ||
custom.lib.hooks # should not fail |
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,16 @@ | ||
from tethys_components import layouts | ||
from unittest import TestCase, mock | ||
from reactpy.core.component import Component | ||
|
||
|
||
class TestComponentLayouts(TestCase): | ||
|
||
@mock.patch("tethys_components.layouts.HeaderWithNavBar", return_value={}) | ||
def test_NavHeader(self, _): | ||
test_layout = layouts.NavHeader({ | ||
'app': mock.MagicMock(), | ||
'user': mock.MagicMock(), | ||
'nav-links': mock.MagicMock() | ||
}) | ||
self.assertIsInstance(test_layout, Component) | ||
self.assertIsInstance(test_layout.render(), dict) |
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
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
3 changes: 3 additions & 0 deletions
3
tests/unit_tests/test_tethys_portal/test_views/test_accounts.py
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
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
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
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
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
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
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
Oops, something went wrong.