Fixed tests.
This commit is contained in:
parent
01de75bef3
commit
8bb2a002a6
@ -61,6 +61,7 @@ def process_and_display_chat(args: argparse.Namespace,
|
|||||||
display_chat(chat, dump, args.only_source_code)
|
display_chat(chat, dump, args.only_source_code)
|
||||||
return chat, full_question, tags
|
return chat, full_question, tags
|
||||||
|
|
||||||
|
|
||||||
def process_and_display_tags(args: argparse.Namespace,
|
def process_and_display_tags(args: argparse.Namespace,
|
||||||
config: dict,
|
config: dict,
|
||||||
dump: bool = False
|
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', '--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('-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-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('-W', '--with-file',
|
||||||
parser.add_argument('-a', '--match-all-tags', help="All given tags must match when selecting chat history entries.", action='store_true')
|
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 = parser.add_argument('-t', '--tags', nargs='*', help='List of tag names', metavar='TAGS')
|
||||||
tags_arg.completer = tags_completer # type: ignore
|
tags_arg.completer = tags_completer # type: ignore
|
||||||
extags_arg = parser.add_argument('-e', '--extags', nargs='*', help='List of tag names to exclude', metavar='EXTAGS')
|
extags_arg = parser.add_argument('-e', '--extags', nargs='*', help='List of tag names to exclude', metavar='EXTAGS')
|
||||||
|
|||||||
@ -111,5 +111,6 @@ def get_tags(config: Dict[str, Any], prefix: Optional[str]) -> List[str]:
|
|||||||
result.append(tag)
|
result.append(tag)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_tags_unique(config: Dict[str, Any], prefix: Optional[str]) -> List[str]:
|
def get_tags_unique(config: Dict[str, Any], prefix: Optional[str]) -> List[str]:
|
||||||
return list(set(get_tags(config, prefix)))
|
return list(set(get_tags(config, prefix)))
|
||||||
|
|||||||
@ -95,7 +95,10 @@ class TestHandleQuestion(unittest.TestCase):
|
|||||||
question=[self.question],
|
question=[self.question],
|
||||||
source=None,
|
source=None,
|
||||||
only_source_code=False,
|
only_source_code=False,
|
||||||
number=3
|
number=3,
|
||||||
|
match_all_tags=False,
|
||||||
|
with_tags=False,
|
||||||
|
with_file=False,
|
||||||
)
|
)
|
||||||
self.config = {
|
self.config = {
|
||||||
'db': 'test_files',
|
'db': 'test_files',
|
||||||
@ -119,7 +122,8 @@ class TestHandleQuestion(unittest.TestCase):
|
|||||||
mock_create_chat.assert_called_once_with(self.question,
|
mock_create_chat.assert_called_once_with(self.question,
|
||||||
self.args.tags,
|
self.args.tags,
|
||||||
self.args.extags,
|
self.args.extags,
|
||||||
self.config)
|
self.config,
|
||||||
|
False, False, False)
|
||||||
mock_pp.assert_called_once_with("test_chat")
|
mock_pp.assert_called_once_with("test_chat")
|
||||||
mock_ai.assert_called_with("test_chat",
|
mock_ai.assert_called_with("test_chat",
|
||||||
self.config,
|
self.config,
|
||||||
@ -203,7 +207,7 @@ class TestCreateParser(unittest.TestCase):
|
|||||||
mock_add_mutually_exclusive_group.assert_called_once_with(required=True)
|
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('-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('-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-dump', help="Print chat history 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', help="Print chat history as readable text", action='store_true')
|
||||||
self.assertTrue('.config.yaml' in parser.get_default('config'))
|
self.assertTrue('.config.yaml' in parser.get_default('config'))
|
||||||
self.assertEqual(parser.get_default('number'), 1)
|
self.assertEqual(parser.get_default('number'), 1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user