Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/justpy-org/justpy
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Nov 15, 2022
2 parents 3c135bf + 5608537 commit 826d4f7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/test_aggrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
Created on 2022-11-14
@author: th
"""
import asyncio
import datetime

import pandas as pd


import justpy as jp
from tests.base_selenium_test import BaseSeleniumTest


class TestAgGrid(BaseSeleniumTest):
"""
testing AgGrid integration
"""

async def setUp(self, **kwargs):
"""
setup test environment
"""
await super().setUp(port=8124, **kwargs)
self.data = [
{"name": "Bob", "age": 42, "birthdate": datetime.date(year=2000, month=1, day=1)},
{"name": "Alice", "age": 24, "birthdate": datetime.date(year=2022, month=1, day=1)},
]

async def tearDown(self):
"""
close test environment
"""
self.browser.close()
await asyncio.sleep(self.server.sleep_time)
await self.server.stop()

async def test_load_pandas_frame(self):
"""
tests loading a pandas dataframe into AgGrid
"""

def table_from_dataframe() -> jp.WebPage:
"""
load AgGrid from dataframe
"""
df = pd.DataFrame.from_records(self.data)
df['birthdate'] = pd.to_datetime(df['birthdate'])
wp = jp.WebPage()
aggrid_table = jp.AgGrid(a=wp)
aggrid_table.load_pandas_frame(df)
return wp

await self.server.start(table_from_dataframe)
url = self.server.get_url("/")
# test setting of col_filter

# test display of data

0 comments on commit 826d4f7

Please sign in to comment.