Skip to content

Commit

Permalink
add e2e tests for TableDisplay for pandas (#6766)
Browse files Browse the repository at this point in the history
* add test for DisplayTable for pandas

* refactor test for regression
  • Loading branch information
EfimovVladimir authored and scottdraves committed Feb 5, 2018
1 parent dac0d12 commit a52d0fd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 182 deletions.
222 changes: 40 additions & 182 deletions test/notebooks/python/TableAPIPythonTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ff5a93cd997a4b328da0a945a318f1e9",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from beakerx import *\n",
"\n",
Expand All @@ -25,147 +13,63 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ac0cc4994a5e4b42a6450f3fd31c5c23",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay([{\"a\":1}, {\"a\":10, \"b\":20}])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "44739125e1fe4a4e9588fe63e238c969",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay({\"a\":1/10, \"b\":1/20, \"c\":0.33})"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cc64654431eb4593ac7c86513b3366c2",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay([{\"a\":1/10}, {\"a\":1/100, \"b\":3.12345}])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e79bab35802f4a05be0ab016234d028d",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay({\"a\":'a a a', \"b\":'b b b', \"c\":'c c c'})"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "64de21cbaf8f47ca8750c56ad189e03e",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay([{\"a\":'a'}, {\"a\":'1a', \"b\":'2b'}])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "05fb389e29c5407aa32e56320053d460",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay({\"a\":[1, 2, 3], \"b\":[10, 20, 30], \"c\":[100, 200, 300]})"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c5d1ad52fd6d4a179cba5b43c54e8ab0",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay([\n",
" {\"a\":[1, 2, 3]}, \n",
Expand All @@ -174,21 +78,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ec30451cae454de1b332a956460cd63f",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"row1 = {\"a\":100, \"b\":200, \"c\":300}\n",
"row2 = {\"a\":1/10, \"b\":1/20, \"c\":0.33}\n",
Expand All @@ -199,42 +91,18 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "68294a8a625047cda4e6fe7008ac834f",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay({\"a\":100, \"b\":1/20, \"c\":'c c c', \"d\":[100, 200, 300]})"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f685684b3bb1428386a66a01fdc6367e",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"row1 = {\"a\":10, \"b\":1/10, \"c\":'c', \"d\":[100, 200]}\n",
"row2 = {\"a\":100, \"b\":1/20, \"c\":'c c c', \"d\":[100, 200, 300]}\n",
Expand All @@ -243,48 +111,38 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fa82ef9ddd2f411db45a64086b5efef4",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"TableDisplay({10:20, 1/10:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]})"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "58fe95c025114071941c312180843d4c",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"row1 = {10:10, 1/10:1/10, 'c':'c'}\n",
"row2 = {10:20, 1/10:1/20, 'c':'c c c', '[100, 200]':[100, 200, 300]}\n",
"TableDisplay([row1, row2])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from beakerx import *\n",
"\n",
"df = pd.DataFrame({\"runway\": [\"24\", \"36L\"]})\n",
"\n",
"TableDisplay(df)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
9 changes: 9 additions & 0 deletions test/tests/python/tableAPIPythonTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ describe('Testing of table (python)', function () {
checkTableRows(tBody, 2);
checkHeaderValues(tHead, '10', '0\.1');
});
});

describe("TableDisplay(pandas DataFrame)", function() {
it('TableDisplay should display table from pandas dataFrame', function () {
cellIndex += 1;
var dtContainer = beakerxPO.runCellToGetDtContainer(cellIndex);
var tBody = tableHelper.getDataTableBody(dtContainer);
expect(tableHelper.getTableBodyCell(tBody, 0, 1).getText()).toMatch('24');
expect(tableHelper.getTableBodyCell(tBody, 1, 1).getText()).toMatch('36L');
});
});

});

0 comments on commit a52d0fd

Please sign in to comment.