def test_parse_invalid_promotezip(self) -> None: """Test parse with invalid promotezip value.""" with pytest.raises(ValidationError): assert not ServerlessOptions.parse_obj( {"promotezip": { "key": "value" }})
def test_parse(self, config): """Test parse.""" obj = ServerlessOptions.parse(**config) assert obj.args == config.get('args', []) assert obj.extend_serverless_yml == \ config.get('extend_serverless_yml', {}) assert obj.promotezip == config.get('promotezip', {}) assert obj.skip_npm_ci == config.get('skip_npm_ci', False)
def test_parse(self, config): """Test parse.""" obj = ServerlessOptions.parse(**config) assert obj.args == config.get("args", []) assert obj.extend_serverless_yml == config.get("extend_serverless_yml", {}) assert obj.promotezip == config.get("promotezip", {}) assert obj.skip_npm_ci == config.get("skip_npm_ci", False)
def test_parse(self, config: Dict[str, Any]) -> None: """Test parse.""" obj = ServerlessOptions.parse_obj(config) assert obj.args == config.get("args", []) assert obj.extend_serverless_yml == config.get( "extend_serverless_yml", cast(Dict[str, Any], {})) if config.get("promotezip"): assert obj.promotezip else: assert not obj.promotezip assert obj.promotezip.bucketname == config.get( "promotezip", cast(Dict[str, Any], {})).get("bucketname") assert obj.skip_npm_ci == config.get("skip_npm_ci", False)
def test_update_args(self): """Test update_args.""" obj = ServerlessOptions( args=['--config', 'something', '--unknown-arg', 'value'], extend_serverless_yml={}, promotezip={}) assert obj.args == ['--config', 'something', '--unknown-arg', 'value'] obj.update_args('config', 'something-else') assert obj.args == [ '--config', 'something-else', '--unknown-arg', 'value' ] with pytest.raises(KeyError): obj.update_args('invalid-key', 'anything')
def test_update_args(self): """Test update_args.""" obj = ServerlessOptions( args=["--config", "something", "--unknown-arg", "value"], extend_serverless_yml={}, promotezip={}, ) assert obj.args == ["--config", "something", "--unknown-arg", "value"] obj.update_args("config", "something-else") assert obj.args == [ "--config", "something-else", "--unknown-arg", "value" ] with pytest.raises(KeyError): obj.update_args("invalid-key", "anything")
def test_args(self, args: List[str], expected: List[str]) -> None: """Test args.""" obj = ServerlessOptions.parse_obj({"args": args}) assert obj.args == expected
def test_parse_invalid_promotezip(self): """Test parse with invalid promotezip value.""" with pytest.raises(ValueError): assert not ServerlessOptions.parse(promotezip={'key': 'value'})
def test_args(self, args, expected): """Test args.""" obj = ServerlessOptions(args=args, extend_serverless_yml={}, promotezip={}) assert obj.args == expected