def test_skip(self, caplog, monkeypatch, runway_context, tmp_path): """Test skip.""" caplog.set_level(logging.INFO, logger="runway") obj = Serverless(runway_context, tmp_path) monkeypatch.setattr(obj, "package_json_missing", lambda: True) monkeypatch.setattr(obj, "env_file", False) assert obj.skip assert [ '{}:skipped; package.json with "serverless" in devDependencies' " is required for this module type".format(tmp_path.name) ] == caplog.messages caplog.clear() monkeypatch.setattr(obj, "package_json_missing", lambda: False) assert obj.skip assert [ "{}:skipped; config file for this stage/region not found" " -- looking for one of: {}".format( tmp_path.name, ", ".join(gen_sls_config_files(obj.stage, obj.region))) ] == caplog.messages caplog.clear() obj.environments = True assert not obj.skip obj.environments = False obj.parameters = True assert not obj.skip obj.parameters = False obj.env_file = True assert not obj.skip
def test_skip( self, caplog: LogCaptureFixture, mocker: MockerFixture, runway_context: MockRunwayContext, tmp_path: Path, ) -> None: """Test skip.""" caplog.set_level(logging.INFO, logger="runway") obj = Serverless(runway_context, module_root=tmp_path) mocker.patch.object(obj, "package_json_missing", lambda: True) mocker.patch.object(obj, "env_file", False) assert obj.skip assert [ '{}:skipped; package.json with "serverless" in devDependencies' " is required for this module type".format(tmp_path.name) ] == caplog.messages caplog.clear() mocker.patch.object(obj, "package_json_missing", lambda: False) assert obj.skip assert [ "{}:skipped; config file for this stage/region not found" " -- looking for one of: {}".format( tmp_path.name, ", ".join(gen_sls_config_files(obj.stage, obj.region))) ] == caplog.messages caplog.clear() obj.explicitly_enabled = True assert not obj.skip obj.explicitly_enabled = False obj.parameters = True # type: ignore assert not obj.skip obj.parameters = False # type: ignore obj.env_file = True # type: ignore assert not obj.skip
def test_skip(self, caplog, monkeypatch, runway_context, tmp_path): """Test skip.""" caplog.set_level(logging.WARNING, logger='runway') obj = Serverless(runway_context, tmp_path) monkeypatch.setattr(obj, 'package_json_missing', lambda: True) monkeypatch.setattr(obj, 'env_file', False) assert obj.skip assert [ '{}: The Serverless module type requires a package file ' 'specifying serverless in devDependencies'.format(tmp_path.name), '{}: Skipping module'.format(tmp_path.name) ] == caplog.messages caplog.clear() monkeypatch.setattr(obj, 'package_json_missing', lambda: False) assert obj.skip assert [ '{}: No config file for this stage/region found (looking for ' 'one of "{}")'.format( tmp_path.name, ', '.join(gen_sls_config_files(obj.stage, obj.region))), '{}: Skipping module'.format(tmp_path.name) ] == caplog.messages caplog.clear() obj.environments = True assert not obj.skip obj.environments = False obj.parameters = True assert not obj.skip obj.parameters = False obj.env_file = True assert not obj.skip