Skip to content

Commit

Permalink
add some tests, activate coverage report (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzoic committed Nov 8, 2023
1 parent acc5ca2 commit de14064
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/run-tests-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# - run: xvfb-run pytest tests/
- run: tests/cmd_tests.sh

run-tests-ubuntu-22_04-python-3_10:
run-tests-ubuntu-22_04-python-3_10-with-coverage:
runs-on: ubuntu-22.04
name: Ubuntu 22.04, Python 3.10
steps:
Expand All @@ -28,8 +28,13 @@ jobs:
- run: sudo apt install xvfb
- run: pip install --upgrade pip
- run: pip install .[dev]
- run: xvfb-run pytest tests/
- run: xvfb-run coverage run --source countess -m pytest tests/
- run: coverage html
- run: tests/cmd_tests.sh
- uses: actions/upload-artifact@v3
with:
name: test coverage report
path: htmlcov/index.html

# run-tests-ubuntu-22_04-python-3_11_0rc2:
# runs-on: ubuntu-22.04
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies = [
dev = [
'black<24',
'build==0.10.0',
'coverage==7.3.2',
'mypy~=1.0.1',
'pylint~=2.17',
'types-psutil~=5.9.5',
Expand Down
39 changes: 39 additions & 0 deletions tests/utils/test_pandas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest

import pandas as pd

from countess.utils.pandas import *

df0 = pd.DataFrame([])
df1 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(0,100) ]).set_index('a')
df2 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(100,1000) ]).set_index('a')
df3 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(1000,10000) ]).set_index('a')
df4 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10000,10100) ]).set_index('a')
df5 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10100,10200) ]).set_index('a')
df6 = pd.DataFrame([ {'a': n, 'b': n*100 } for n in range(10200,10300) ]).set_index('a')

def assert_iterable_of_dataframes_equal(a,b):

assert pd.concat(a).sort_index().equals(
pd.concat(b).sort_index()
)

def test_collect_dataframes_0():

x = list(collect_dataframes([df0,df0,None,df0].__iter__()))
assert len(x) == 0

def test_collect_dataframes_1():
x = list(collect_dataframes([df1,df4,df5].__iter__(), 300))
assert_iterable_of_dataframes_equal([df1,df4,df5], x)
assert min(len(y) for y in x) > 100

def test_collect_dataframes_2():
x = list(collect_dataframes([df1,df2,df4,df5].__iter__(), 300))
assert_iterable_of_dataframes_equal([df1,df2,df4,df5], x)
assert min(len(y) for y in x) > 100

def test_collect_dataframes_3():
x = list(collect_dataframes([df1,df2,df4,df5,df6].__iter__(), 300))
assert_iterable_of_dataframes_equal([df1,df2,df4,df5,df6], x)
assert len(x) < 5

0 comments on commit de14064

Please sign in to comment.