コード例 #1
0
ファイル: test_edit_item.py プロジェクト: GlenRSmith/Phibes
 def test_editor_option(self, crypt_id, tmp_path, setup_and_teardown):
     self.my_locker = Locker.create(password=self.password,
                                    crypt_id=crypt_id)
     new_item = self.my_locker.create_item(item_name=self.test_item_name)
     new_item.content = self.start_content
     self.my_locker.add_item(item=new_item)
     conf = CliConfig()
     conf.store = {
         'store_type': conf.store['store_type'],
         'store_path': tmp_path
     }
     conf.editor = f'echo {self.edit_content}> '
     write_config_file(tmp_path, update=True)
     load_config_file(tmp_path)
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     replacement_content = "emacswhatwhat"
     cli_editor_option = f"echo {replacement_content}> "
     result = self.prep_and_run({
         'crypt_id': crypt_id,
         'editor': cli_editor_option
     })
     assert result
     assert result.exit_code == 0, (f"{crypt_id=}\n"
                                    f"{result.exception=}\n"
                                    f"{result.output=}\n")
     assert self.start_content not in result.output
     assert self.edit_content not in result.output
     inst = self.my_locker.get_item(self.test_item_name)
     assert replacement_content == inst.content.strip()
コード例 #2
0
ファイル: test_get_item.py プロジェクト: GlenRSmith/Phibes
 def prep_and_run(self, arg_dict):
     self.my_locker = Locker.create(password=self.password,
                                    crypt_id=arg_dict['crypt_id'])
     new_item = self.my_locker.create_item(item_name=self.test_item_name)
     new_item.content = self.test_content
     self.my_locker.add_item(item=new_item)
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     return self.invoke(arg_dict=arg_dict)
コード例 #3
0
ファイル: test_edit_item.py プロジェクト: GlenRSmith/Phibes
 def custom_setup(self, tmp_path):
     super(TestEditBase, self).custom_setup(tmp_path)
     my_item = self.my_locker.create_item(self.good_template_name)
     my_item.content = f"{self.good_template_name}:secret"
     self.my_locker.add_item(my_item)
     CliConfig().editor = "echo 'happyclappy' >> "
     write_config_file(tmp_path, update=True)
     self.setup_command()
     update_config_option_default(self.target_cmd, tmp_path)
コード例 #4
0
 def prep_and_run(self, arg_dict):
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     arg_list = [
         "--path",
         arg_dict.get('path', self.test_path), "--password",
         arg_dict.get('password', self.password), "--crypt_id",
         arg_dict.get('crypt_id')
     ]
     return CliRunner().invoke(cli=self.target_cmd,
                               args=arg_list,
                               input="y\n")
コード例 #5
0
 def test_normal_default_config(self, setup_and_teardown, crypt_id):
     update_config_option_default(self.target_cmd, self.test_path)
     result = CliRunner().invoke(cli=self.target_cmd,
                                 args=[
                                     "--locker", self.locker_name,
                                     "--password", self.pw, "--crypt_id",
                                     crypt_id
                                 ],
                                 input="y\n")
     assert result.exit_code == 0, (f"       {result.output}       "
                                    f"       {result.exit_code}       ")
     assert "created" in result.output
コード例 #6
0
ファイル: test_get_locker.py プロジェクト: GlenRSmith/Phibes
 def prep_and_run(self, arg_dict):
     self.my_locker = Locker.create(
         password=self.password,
         crypt_id=arg_dict['crypt_id'],
         locker_name=None
     )
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     arg_list = [
         "--path", arg_dict.get('path', self.test_path),
         "--password", arg_dict.get('password', self.password)
     ]
     return CliRunner().invoke(cli=self.target_cmd, args=arg_list)
コード例 #7
0
ファイル: test_get_item.py プロジェクト: GlenRSmith/Phibes
 def invoke(self, item_name: str):
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     # get the current config
     config = ConfigModel()
     # persist the changed config
     self.update_config(config)
     return CliRunner().invoke(catch_exceptions=False,
                               cli=self.target_cmd,
                               args=[
                                   "--config", self.test_path, "--password",
                                   self.password, "--locker",
                                   self.locker_name, "--item", item_name
                               ])
コード例 #8
0
 def test_delete_locker_normal(self, setup_and_teardown, crypt_id):
     update_config_option_default(self.target_cmd, self.test_path)
     assert Locker.get(password=self.pw, locker_name=self.locker_name)
     result = CliRunner().invoke(
         cli=self.target_cmd,
         args=["--locker", self.locker_name, "--password", self.pw],
         input="y\n"
     )
     assert result.exit_code == 0, (
         f'{result.exception=}\n'
         f'{result.output=}\n'
     )
     with pytest.raises(PhibesNotFoundError):
         Locker.get(password=self.pw, locker_name=self.locker_name)
コード例 #9
0
ファイル: test_get_locker.py プロジェクト: GlenRSmith/Phibes
 def prep_and_run(self, config_arg, arg_dict):
     if config_arg:
         arg_list = ["--config", self.test_path]
     else:
         arg_list = []
     # change the configured working path to the test directory
     update_config_option_default(self.target_cmd, self.test_path)
     # get the current config
     config = ConfigModel()
     # persist the changed config
     self.update_config(config)
     arg_list += [
         "--locker", arg_dict.get('name', self.locker_name),
         "--password", arg_dict.get('password', self.password)
     ]
     assert 'editor' not in arg_list
     assert '--editor' not in arg_list
     ret_val = CliRunner().invoke(
         cli=self.target_cmd, args=arg_list
     )
     return ret_val