def test_crypt_file_ok(self): crypt = Crypt() crypt.generate_key("mypassword", True) arguments = ["encrypt", "prueba"] cmd = Command(arguments=arguments, autorun=False) cmd.run() crypt.delete_key()
def test_create_config_all(self, input): # Remove config file if already exists for test remove_conf_file() arguments = ["create-config"] cmd = Command(arguments=arguments, autorun=False) assert cmd.run() assert not cmd.run() remove_conf_file()
def test_generate_file_ok(self, input): crypt = Crypt() arguments = [ "create-key", ] cmd = Command(arguments=arguments, autorun=False) cmd.run() crypt.delete_key()
def test_crypt_file_error(self): arguments = ["encrypt", "prueba"] cmd = Command(arguments=arguments, autorun=False) with pytest.raises(FileDoesNotExistException) as excinfo: cmd.run() assert ( "Decrypt key None not exists. You must set a correct env var PYMS_KEY_FILE or run " "`pyms crypt create-key` command") in str(excinfo.value)
def test_output_key(self, input): crypt = Crypt() arguments = ["create-key", ] cmd = Command(arguments=arguments, autorun=False) cmd.run() with pytest.raises(FileNotFoundError) as excinfo: crypt.delete_key() assert "[Errno 2] No such file or directory: 'key.key'" in str(excinfo.value)
def test_merge_swagger_ok(self): arguments = [ "merge-swagger", "--file", "tests/swagger_for_tests/swagger.yaml", ] cmd = Command(arguments=arguments, autorun=False) assert cmd.run() os.remove("tests/swagger_for_tests/swagger-complete.yaml")
def test_merge_swagger_error(self): arguments = ["merge-swagger", ] cmd = Command(arguments=arguments, autorun=False) assert not cmd.run()
def test_startproject_error(self): arguments = ["startproject"] cmd = Command(arguments=arguments, autorun=False) with pytest.raises(PackageNotExists) as excinfo: cmd.run() assert "cookiecutter is not installed. try with pip install -U cookiecutter" in str(excinfo.value)
def test_merge_swagger_error(self): arguments = ["merge-swagger", ] cmd = Command(arguments=arguments, autorun=False) with pytest.raises(ResolutionError) as excinfo: cmd.run()