Skip to content

Commit

Permalink
test fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzoic committed Nov 9, 2023
1 parent 9c2d59a commit b07b8a5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 25 deletions.
2 changes: 0 additions & 2 deletions countess/gui/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ def refresh(self, new_offset=0):
self.offset = new_offset
if self.length:
self.scrollbar.set(self.offset / self.length, (self.offset + self.height) / self.length)
else:
self.scrollbar.set(0, 1)

def scrollto(self, new_offset):
self.offset = min(max(int(new_offset), 0), self.length - self.height)
Expand Down
27 changes: 4 additions & 23 deletions tests/gui/test_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,10 @@ def test_tabular_scroll():

tt.set_dataframe(dfx)

root.update()
time.sleep(0.1)

tt.refresh(10)

root.update()
time.sleep(0.1)

tt.refresh(0)

root.update()
time.sleep(0.1)

tt.refresh(6666)

root.update()
time.sleep(0.1)

tt.refresh(3333)

root.update()
time.sleep(0.1)

for offset in (10, 0, 6666, 6660, 3333):
time.sleep(0.1)
tt.refresh(offset)
root.update()

def test_tabular_copy():
root = make_root()
Expand Down
58 changes: 58 additions & 0 deletions tests/plugins/test_data_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from countess.plugins.data_table import DataTablePlugin

from countess.core.logger import MultiprocessLogger

logger = MultiprocessLogger()

def test_data_table():
plugin = DataTablePlugin()
assert plugin.num_files() == 1

plugin.set_parameter('columns.0.name', 'foo')
plugin.set_parameter('columns.0.type', 'string')
plugin.set_parameter('columns.0.index', True)
plugin.set_parameter('columns.1.name', 'bar')
plugin.set_parameter('columns.1.type', 'integer')
plugin.set_parameter('columns.2.name', 'baz')
plugin.set_parameter('columns.2.type', 'number')
plugin.set_parameter('rows.0.0', 'a')
plugin.set_parameter('rows.0.1', '1')
plugin.set_parameter('rows.0.2', '4.5')
plugin.set_parameter('rows.1.0', 'b')
plugin.set_parameter('rows.1.1', '2')
plugin.set_parameter('rows.1.2', '5.6')
plugin.set_parameter('rows.2.0', 'c')
plugin.set_parameter('rows.2.1', '3')
plugin.set_parameter('rows.2.2', '6.7')

df = next(plugin.load_file(0, logger, None))

assert len(df) == 3
assert df['bar'].iloc[0] == 1
assert df['baz'].iloc[2] == 6.7
assert df.index[0] == 'a'

plugin.set_parameter('columns.1.type', 'number')
plugin.set_parameter('columns.2.type', 'integer')
plugin.set_parameter('columns.3.name', 'hello')
plugin.set_parameter('columns.3.type', 'string')
plugin.fix_columns()
plugin.set_parameter('rows.2.3', 'world')
df = next(plugin.load_file(0, logger, None))

assert df['bar'].iloc[0] == 1.0
assert df['baz'].iloc[1] == 5
assert df['hello'].iloc[2] == 'world'

plugin.set_parameter('columns.3.type', 'number')
plugin.fix_columns()
df = next(plugin.load_file(0, logger, None))

assert df['hello'].iloc[2] is None

plugin.parameters['columns'].del_row(1)
plugin.fix_columns()

df = next(plugin.load_file(0, logger, None))
assert 'bar' not in df.columns

0 comments on commit b07b8a5

Please sign in to comment.