Skip to content

Commit

Permalink
[Refactoring] improve the data of view_tables function Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrMohamad committed Dec 12, 2022
1 parent 0f09dbc commit 46abf30
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
Binary file modified __pycache__/pykanban.cpython-310.pyc
Binary file not shown.
Binary file modified __pycache__/test_pykanban.cpython-310-pytest-7.1.3.pyc
Binary file not shown.
Binary file modified __pycache__/test_pykanban.cpython-310-pytest-7.2.0.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion pykanban.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def init_table(table_name: str) -> str:

def view_tables() -> list[str]:
dir_path = f"{DATA_DIR}"
if len(os.listdir(dir_path)) == 0 or '.DS_Store' in os.listdir(dir_path):
c = os.listdir(dir_path)
if os.listdir(dir_path) == ['.DS_Store'] or len(os.listdir(dir_path)) == 0:
return f"No Tables Exist"
tables_list = []
for path in os.scandir(dir_path):
Expand Down
4 changes: 4 additions & 0 deletions test_pykanban.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ def test_init_table():

def test_view_tables():
destination = "./test_data"
os.mkdir("./data/_temp/")
temp = open("./data/_temp/latest.csv","w")
temp.close()
os.mkdir(destination)
# shutil.rmtree(f'{destination}/.DS_Store')
for f in os.listdir("./data"):
Expand All @@ -298,6 +301,7 @@ def test_view_tables():
name_tables.append(nt)
assert view_tables() == name_tables
os.rmdir(destination)
shutil.rmtree("./data/_temp/")
...


Expand Down

0 comments on commit 46abf30

Please sign in to comment.