Skip to content

Commit

Permalink
test embedded_files in API
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarragher committed Oct 19, 2021
1 parent 6553b20 commit 8d714fa
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_vault_instantiation(tmp_path):
assert isinstance(actual_vault.is_connected, bool)
assert actual_vault.backlinks_index == {}
assert actual_vault.wikilinks_index == {}
assert actual_vault.embedded_files_index == {}
assert actual_vault.md_links_index == {}
assert actual_vault.nonexistent_notes == []
assert actual_vault.isolated_notes == []
Expand All @@ -55,6 +56,11 @@ def test_get_wikilinks_index(mock_initial_vault):
assert isinstance(mock_output, dict)


def test_get_embedded_files_index(mock_initial_vault):
mock_output = mock_initial_vault._get_embedded_files_index()
assert isinstance(mock_output, dict)


def test_get_unique_wikilinks_index(mock_initial_vault):
mock_output = mock_initial_vault._get_unique_wikilinks_index()
assert isinstance(mock_output, dict)
Expand All @@ -74,6 +80,7 @@ def test_connect(mock_initial_vault):
assert isinstance(mock_initial_vault.graph, nx.MultiDiGraph)
assert isinstance(mock_initial_vault.backlinks_index, dict)
assert isinstance(mock_initial_vault.wikilinks_index, dict)
assert isinstance(mock_initial_vault.embedded_files_index, dict)
assert isinstance(mock_initial_vault.md_links_index, dict)
assert isinstance(mock_initial_vault.nonexistent_notes, list)
assert isinstance(mock_initial_vault.isolated_notes, list)
Expand All @@ -91,6 +98,8 @@ def test_functions_to_fail_for_unconnected_vault(mock_initial_vault):
mock_initial_vault.get_backlink_counts('A note that would not exist')
with pytest.raises(AttributeError):
mock_initial_vault.get_wikilinks('A note that would not exist')
with pytest.raises(AttributeError):
mock_initial_vault.get_embedded_files('A note that would not exist')
with pytest.raises(AttributeError):
mock_initial_vault.get_front_matter('A note that would not exist')
with pytest.raises(AttributeError):
Expand Down
37 changes: 36 additions & 1 deletion tests/test_api_vault_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,37 @@ def expected_metadata_dict():
'Virtus': np.NaN,
'Tydides': np.NaN,
'Dives': np.NaN,
'Aetna': np.NaN}
'Aetna': np.NaN},
'n_embedded_files': {'Sussudio': 0.0,
'Brevissimus moenia': 0.0,
'Ne fuit': 0.0,
'Alimenta': 0.0,
'Vulnera ubera': 0.0,
'Causam mihi': 0.0,
'Tarpeia': np.NaN,
'Caelum': np.NaN,
'Vita': np.NaN,
'Aras Teucras': np.NaN,
'Manus': np.NaN,
'Bacchus': np.NaN,
'Amor': np.NaN,
'Virtus': np.NaN,
'Tydides': np.NaN,
'Dives': np.NaN,
'Aetna': np.NaN}
}


@pytest.fixture
def expected_embedded_files_index():
return {'Sussudio': [],
'Brevissimus moenia': [],
'Ne fuit': [],
'Alimenta': [],
'Vulnera ubera': [],
'Causam mihi': []}


@pytest.fixture
def expected_front_matter_index():
return {'Sussudio': {'title': 'Sussudio',
Expand Down Expand Up @@ -141,6 +168,7 @@ def test_get_metadata_cols(actual_metadata_df):
expected_cols = ['rel_filepath', 'abs_filepath',
'note_exists',
'n_backlinks', 'n_wikilinks',
'n_embedded_files',
'modified_time']
assert actual_metadata_df.columns.tolist() == expected_cols

Expand All @@ -151,6 +179,7 @@ def test_get_metadata_dtypes(actual_metadata_df):
assert actual_metadata_df['note_exists'].dtype == 'bool'
assert actual_metadata_df['n_backlinks'].dtype == 'int'
assert actual_metadata_df['n_wikilinks'].dtype == 'float'
assert actual_metadata_df['n_embedded_files'].dtype == 'float'
assert actual_metadata_df['modified_time'].dtype == 'datetime64[ns]'


Expand Down Expand Up @@ -341,6 +370,12 @@ def test_nodes_gte_files(actual_connected_vault):
assert act_n_len >= act_f_len


def test_embedded_files_index(
actual_connected_vault, expected_embedded_files_index):
actual_files_ix = actual_connected_vault.embedded_files_index
assert actual_files_ix == expected_embedded_files_index


def test_md_links_index(
actual_connected_vault, expected_md_links_index):
actual_md_links_ix = actual_connected_vault.md_links_index
Expand Down

0 comments on commit 8d714fa

Please sign in to comment.