Skip to content

Commit 2d0ef6c

Browse files
committed
TEST: added test cases to expose undocumented/broken behaviour
1 parent 4054615 commit 2d0ef6c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ python server.py
1717
### Pre-requisite install scry.
1818
Follow the repo https://github.com/scryInfo/scry/ to install full system.
1919

20-
### Testing
20+
### Integration Testing
2121
open the front end
2222
create a user with login=22 password=22
2323
```
2424
python -m demo.demo_publisher
2525
2626
python test server.py
2727
```
28+
29+
### Unit Testing
30+
For now there is only 1 unit test class
31+
```
32+
python -m unittest -v test_server.DataTest
33+
```

test_server.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ class DataTest(unittest.TestCase):
218218

219219
df = pd.DataFrame(data={'col1': ['a', 1,np.nan,np.nan], 'col2': [1, 'a',1,2.2]})
220220

221+
df_valid= pd.DataFrame(data={'col1': [2, 1], 'col2': [1, 2]})
222+
221223
meta=[{"col1":{"DataType": "Int","IsUnique": "true"}},
222224
{"col2":{"DataType": "Int","IsUnique": "true"}}]
223225

@@ -259,6 +261,24 @@ def test_all_tests_for_column(self,df=df):
259261
test_column(df['col1'],{"DataType": "Int","IsUnique": "true"})
260262
,[{'DataType': [[0, 'a'], [2, 'nan'], [3, 'nan']]}, {'IsNull': [[2, 'nan'], [3, 'nan']]}])
261263

264+
def test_dataframe(self):
265+
self.assertEqual(test_dataframe(self.df_valid, self.meta),
266+
[])
267+
268+
def test_dataframe_too_few_meta(self):
269+
# TODO: Charles can you confirm this behaviour is expected or should we improve test_data_frame?
270+
self.assertEqual(test_dataframe(self.df_valid, self.meta[:1]),
271+
[])
272+
273+
def test_dataframe_too_many_meta(self):
274+
# TODO: Charles can you confirm this behaviour is expected or should we improve test_data_frame?
275+
self.assertEqual(test_dataframe(self.df_valid[['col1']], self.meta),
276+
[])
277+
278+
def test_dataframe_incorrect_column_name(self):
279+
# TODO: Charles can you confirm this behaviour is expected or should we improve test_data_frame?
280+
self.assertEqual(test_dataframe(self.df_valid.rename(columns={'col1': 'wrongname'}), self.meta),
281+
[])
262282

263283
def test_all_tests_for_dataframe_with_errors(self, df=df, meta=meta):
264284
self.assertEqual(

0 commit comments

Comments
 (0)