Fixed tests.

This commit is contained in:
Oleksandr Kozachuk 2023-08-05 13:21:17 +02:00
parent 01de75bef3
commit 8bb2a002a6
3 changed files with 17 additions and 7 deletions

View File

@ -61,6 +61,7 @@ def process_and_display_chat(args: argparse.Namespace,
display_chat(chat, dump, args.only_source_code)
return chat, full_question, tags
def process_and_display_tags(args: argparse.Namespace,
config: dict,
dump: bool = False
@ -104,8 +105,12 @@ def create_parser() -> argparse.ArgumentParser:
parser.add_argument('-s', '--source', nargs='*', help='Source add content of a file to the query')
parser.add_argument('-S', '--only-source-code', help='Print only source code', action='store_true')
parser.add_argument('-w', '--with-tags', help="Print chat history with tags.", action='store_true')
parser.add_argument('-W', '--with-file', help="Print chat history with filename.", action='store_true')
parser.add_argument('-a', '--match-all-tags', help="All given tags must match when selecting chat history entries.", action='store_true')
parser.add_argument('-W', '--with-file',
help="Print chat history with filename.",
action='store_true')
parser.add_argument('-a', '--match-all-tags',
help="All given tags must match when selecting chat history entries.",
action='store_true')
tags_arg = parser.add_argument('-t', '--tags', nargs='*', help='List of tag names', metavar='TAGS')
tags_arg.completer = tags_completer # type: ignore
extags_arg = parser.add_argument('-e', '--extags', nargs='*', help='List of tag names to exclude', metavar='EXTAGS')

View File

@ -111,5 +111,6 @@ def get_tags(config: Dict[str, Any], prefix: Optional[str]) -> List[str]:
result.append(tag)
return result
def get_tags_unique(config: Dict[str, Any], prefix: Optional[str]) -> List[str]:
return list(set(get_tags(config, prefix)))

View File

@ -95,7 +95,10 @@ class TestHandleQuestion(unittest.TestCase):
question=[self.question],
source=None,
only_source_code=False,
number=3
number=3,
match_all_tags=False,
with_tags=False,
with_file=False,
)
self.config = {
'db': 'test_files',
@ -119,7 +122,8 @@ class TestHandleQuestion(unittest.TestCase):
mock_create_chat.assert_called_once_with(self.question,
self.args.tags,
self.args.extags,
self.config)
self.config,
False, False, False)
mock_pp.assert_called_once_with("test_chat")
mock_ai.assert_called_with("test_chat",
self.config,
@ -203,7 +207,7 @@ class TestCreateParser(unittest.TestCase):
mock_add_mutually_exclusive_group.assert_called_once_with(required=True)
mock_group.add_argument.assert_any_call('-p', '--print', help='File to print')
mock_group.add_argument.assert_any_call('-q', '--question', nargs='*', help='Question to ask')
mock_group.add_argument.assert_any_call('-D', '--chat-dump', help="Print chat as Python structure", action='store_true')
mock_group.add_argument.assert_any_call('-d', '--chat', help="Print chat as readable text", action='store_true')
mock_group.add_argument.assert_any_call('-D', '--chat-dump', help="Print chat history as Python structure", action='store_true')
mock_group.add_argument.assert_any_call('-d', '--chat', help="Print chat history as readable text", action='store_true')
self.assertTrue('.config.yaml' in parser.get_default('config'))
self.assertEqual(parser.get_default('number'), 1)