Skip to content

Commit

Permalink
refactor(tests): split tests/views.py
Browse files Browse the repository at this point in the history
We use the same structure as in the views themselves.
  • Loading branch information
dchiller committed Aug 26, 2024
1 parent 398311a commit 8833cb8
Show file tree
Hide file tree
Showing 17 changed files with 6,645 additions and 6,481 deletions.
18 changes: 18 additions & 0 deletions django/cantusdb_project/main_app/tests/make_fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,21 @@ def make_fake_source(
source.other_editors.set([make_fake_user()])

return source


def get_random_search_term(target):
"""Helper function for generating a random slice of a string.
Args:
target (str): The content of the field to search.
Returns:
str: A random slice of `target`
"""
if len(target) <= 2:
search_term = target
else:
slice_start = random.randint(0, len(target) - 2)
slice_end = random.randint(slice_start + 2, len(target))
search_term = target[slice_start:slice_end]
return search_term
Loading

0 comments on commit 8833cb8

Please sign in to comment.