Skip to content

Commit

Permalink
[CI] Test AnkiDF help
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed May 3, 2019
1 parent 7c796b0 commit 5b4161b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
13 changes: 9 additions & 4 deletions ankipandas/ankidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,15 @@ def fields_as_columns_to_flds(self, *args, **kwargs):
)

def help(self, columns=None):
""" Print help about all known columns in this AnkiDataFrame. """
if not columns:
columns = list(self.columns)
df = convenience.table_help(columns=columns)
""" Print help about all known columns in this AnkiDataFrame.
Args:
columns: Specific column you are interested in
Returns:
:class:`pandas.DataFrame` with descriptions about each column.
"""
df = convenience.table_help(table=self._anki_table, columns=columns)
return df

# def write(self):
Expand Down
2 changes: 1 addition & 1 deletion ankipandas/convenience_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def table_help(table=None, columns=None, native=None) -> pd.DataFrame:
Returns:
Pandas DataFrame with all matches.
"""
help_path = pathlib.Path(__file__).parent / "data"/ "anki_fields.csv"
help_path = pathlib.Path(__file__).parent / "data" / "anki_fields.csv"
df = pd.read_csv(help_path)
df["Tables"] = df["Tables"].str.split(", ")
if table:
Expand Down
31 changes: 31 additions & 0 deletions ankipandas/test/test_ankidf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

""" Most of the functionality of the AnkiDataFrames is already tested in
test_core, because that saves to write a lot of duplicate code.
Everything else is tested here.
"""

# std
import pathlib
import unittest

# ours
from ankipandas.ankidf import AnkiDataFrame as AnkiDF


class TestAnkiDF(unittest.TestCase):
def setUp(self):
self.db_path = pathlib.Path(__file__).parent / "data" / \
"few_basic_cards" / "collection.anki2"

def test_help(self):
notes = AnkiDF.notes()
hlp = notes.help()
self.assertTrue(
["notes" in tables for tables in hlp["Tables"].values]
)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion ankipandas/test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# ours
from ankipandas.core_functions import *
from ankipandas.ankidf import AnkiDataFrame as AnkiDF
# for hidden
# for hidden imports
import ankipandas.core_functions as core_functions
from ankipandas.test.shared import revlog_cols, note_cols, card_cols

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# needed for readthedocs
pandas
colorlog
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
with (this_dir / "requirements.txt").open() as rf:
requirements = [
req.strip() for req in rf.readlines()
if not req.startswith("#")
if req.strip() and not not req.startswith("#")
]


Expand Down

0 comments on commit 5b4161b

Please sign in to comment.