-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filesystem testing functions init #146
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import datetime | ||
|
||
import tempfile | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
#from pydatarecognition.fsclient import date_encoder, dump_json, FileSystemClient | ||
from collections import defaultdict | ||
from testfixtures import TempDirectory | ||
|
||
from pydatarecognition.fsclient import FileSystemClient | ||
|
||
# def test_date_encoder(): | ||
# day = datetime.date(2021,1,1) | ||
# time = datetime.datetime(2021, 5, 18, 6, 28, 21, 504549) | ||
# assert date_encoder(day) == '2021-01-01' | ||
# assert date_encoder(time) == '2021-05-18T06:28:21.504549' | ||
|
||
# | ||
# def test_dump_json(): | ||
# doc = {"first": {"_id": "first", "name": "me", "date": datetime.date(2021,5,1), | ||
|
@@ -42,15 +38,108 @@ | |
DEFAULT_RC = {} | ||
rc = DEFAULT_RC | ||
|
||
|
||
# FileSystemClient methods tested here | ||
def test_is_alive(): | ||
expected = True #filesystem is always alive! | ||
expected = True # filesystem is always alive! | ||
fsc = FileSystemClient(rc) | ||
actual = fsc.is_alive() | ||
|
||
assert actual == expected | ||
|
||
@pytest.mark.skip("Not written") | ||
|
||
def test_open(): | ||
fsc = FileSystemClient(rc) | ||
fsc.open() | ||
|
||
assert isinstance(fsc.dbs, type(defaultdict(lambda: defaultdict(dict)))) | ||
assert isinstance(fsc.chained_db, type(dict())) | ||
assert not fsc.closed | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_load_json(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_load_yaml(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_load_cif(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_load_database(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_dump_json(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_dump_yaml(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_dump_cif(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_dump_database(): | ||
pass | ||
|
||
|
||
def test_close(): | ||
fsc = FileSystemClient(rc) | ||
fsc.close() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think close this up? Not sure what pep8 has to say about this, but it keeps the tests grouped visually bit better. Do what pep8 says but close up if it has nothign to say. |
||
assert fsc.dbs is None | ||
assert fsc.closed | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_keys(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_collection_names(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_all_documents(): | ||
pass | ||
|
||
# and so on..... | ||
|
||
@pytest.mark.skip("Not written") | ||
def test_insert_one(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_insert_many(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_delete_one(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_find_one(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip("Not written") | ||
def test_update_one(): | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure all your files have a trailing eol at the end. Set up your PyCharm (or whatever) to do it auomatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this. I think it more explicitly tests that close is working because it ensures that something is open before it closes it. I think it is probably better to pass in rc explicitly too for greater readibility (I should have done that with open I guess):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't reference rc since I had to make a new class. For now, I just checked if fsc.dbs is an
instanceof
nested dicts.