refactor tests.utils
@@ -22,18 +22,18 @@ def get_search_query_from_project_file(project_slug, page_num=0, data_type='titl
# uses first word of page title as query
query = query_data.split()[0]
- elif data_type.startswith('sections'):
+ elif data_type == 'sections.title':
# generates query from section title
- if data_type.endswith('title'):
query_data = query_data[0]['title'].split()
start = 0
end = random.randint(1, len(query_data))
query = query_data[start:end]
query = ' '.join(query)
+ elif data_type == 'sections.content':
+
# generates query from section content
- elif data_type.endswith('content'):
query_data = query_data[0]['content'].split()
start = random.randint(0, 6)
@@ -45,19 +45,19 @@ def get_search_query_from_project_file(project_slug, page_num=0, data_type='titl
query = query_data[start:end]
query = ' '.join(query)
- elif data_type.startswith('domains'):
+ elif data_type == 'domains.type_display':
# uses first word of domains.type_display as query
- if data_type.endswith('type_display'):
query = query_data[0]['type_display'].split()[0]
- # generates query from domains.name
- if data_type.endswith('name'):
+ elif data_type == 'domains.name':
# test data contains domains.name
# some of which contains '.' and some '/'
# and others are plain words.
# Splitting with '.' and '/' is done
# to ensure that the query contains proper words
+
+ # generates query from domains.name
if '.' in query_data[0]['name']:
query_data = query_data[0]['name'].split('.')
start = 0
