Skip to content

Commit

Permalink
finished
Browse files Browse the repository at this point in the history
  • Loading branch information
hagen-danswer committed Jan 7, 2025
1 parent dc55bae commit 7e91dba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@
_VALID_PREFIX = "file_"


def filter_invalid_prefixes(names: set[str]) -> set[str]:
return {name for name in names if name.startswith(_VALID_PREFIX)}


def print_discrepencies(
expected: set[str],
retrieved: set[str],
) -> None:
# Filter retrieved set to only include valid prefixed items
filtered_retrieved = {name for name in retrieved if name.startswith(_VALID_PREFIX)}
filtered_retrieved = filter_invalid_prefixes(retrieved)
if expected != filtered_retrieved:
print(expected)
print(filtered_retrieved)
Expand Down
9 changes: 6 additions & 3 deletions backend/tests/daily/connectors/google_drive/test_slim_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from tests.daily.connectors.google_drive.consts_and_utils import ADMIN_FILE_IDS
from tests.daily.connectors.google_drive.consts_and_utils import ADMIN_FOLDER_3_FILE_IDS
from tests.daily.connectors.google_drive.consts_and_utils import file_name_template
from tests.daily.connectors.google_drive.consts_and_utils import filter_invalid_prefixes
from tests.daily.connectors.google_drive.consts_and_utils import FOLDER_1_1_FILE_IDS
from tests.daily.connectors.google_drive.consts_and_utils import FOLDER_1_2_FILE_IDS
from tests.daily.connectors.google_drive.consts_and_utils import FOLDER_1_FILE_IDS
Expand Down Expand Up @@ -81,7 +82,8 @@ def assert_correct_access_for_user(
all_accessible_ids = expected_access_ids + PUBLIC_RANGE
expected_file_names = {file_name_template.format(i) for i in all_accessible_ids}

print_discrepencies(expected_file_names, retrieved_file_names)
filtered_retrieved_file_names = filter_invalid_prefixes(retrieved_file_names)
print_discrepencies(expected_file_names, filtered_retrieved_file_names)

assert expected_file_names == retrieved_file_names

Expand Down Expand Up @@ -172,8 +174,9 @@ def test_all_permissions(
}

# Should get everything
print_discrepencies(expected_file_names, found_file_names)
assert expected_file_names == found_file_names
filtered_retrieved_file_names = filter_invalid_prefixes(found_file_names)
print_discrepencies(expected_file_names, filtered_retrieved_file_names)
assert expected_file_names == filtered_retrieved_file_names

group_map = get_group_map(google_drive_connector)

Expand Down

0 comments on commit 7e91dba

Please sign in to comment.