예제 #1
0
    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
예제 #2
0
    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