Skip to content

Conversation

@timabrmsn
Copy link
Contributor

No description provided.

logger.print_and_log_error(u"You cannot use --advanced-query with additional search args.")
exit(1)
def exit_if_advanced_query_used_with_other_search_args(args, search_arg_enum):
invalid_args = ["begin", "end", "incremental"] + list(search_arg_enum)
Copy link
Contributor

@alanag13 alanag13 Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we moved --format out of search_shared.create_search_args() (seems like it could easily be useful elsewhere), we could have invalid_args be set tosearch_shared.create_search_args() - ["advanced_query"]. This would keep invalid_args in sync if we need to add more search args in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just put all the incompatible args into their own function and used that to build the list.

@alanag13
Copy link
Contributor

alanag13 commented Jun 3, 2020

@timabrmsn looks good, can you add tests that mock the result of create_advanced_query_incompatible_search_args() and assert that exit_if_advanced_query_used_with_other_search_args() exits/doesn't exit depending on whether the args passed to it contain one of the items returned by create_advanced_query_incompatible_search_args()?

@timabrmsn timabrmsn merged commit 670c8d5 into master Jun 4, 2020
@timabrmsn timabrmsn deleted the bugfix/search_arg_validation branch July 9, 2020 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants