8000 Add main file by di · Pull Request #31 · GoogleCloudPlatform/functions-framework-python · GitHub
[go: up one dir, main page]

Skip to content

Add main file #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Add support for running `python -m functions_framework` ([#31])
- Move `functions_framework.cli.cli` to `functions_framework._cli._cli`

## [1.2.0] - 2020-02-20
### Added
Expand Down Expand Up @@ -41,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[1.0.1]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.0.1
[1.0.0]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.0.0

[#31]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/31
[#20]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/20
[#14]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/14
[#12]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/12
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
extras_require={"test": ["pytest", "tox"]},
entry_points={
"console_scripts": [
"functions-framework=functions_framework.cli:cli",
"functions_framework=functions_framework.cli:cli",
"ff=functions_framework.cli:cli",
"functions-framework=functions_framework._cli:_cli",
"functions_framework=functions_framework._cli:_cli",
"ff=functions_framework._cli:_cli",
]
},
)
3 changes: 3 additions & 0 deletions src/functions_framework/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from functions_framework._cli import _cli

_cli(prog_name="python -m functions_framework")
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@click.option("--port", envvar="PORT", type=click.INT, default=8080)
@click.option("--debug", envvar="DEBUG", is_flag=True)
@click.option("--dry-run", envvar="DRY_RUN", is_flag=True)
def cli(target, source, signature_type, host, port, debug, dry_run):
def _cli(target, source, signature_type, host, port, debug, dry_run):
app = create_app(target, source, signature_type)
if dry_run:
click.echo("Function: {}".format(target))
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import functions_framework

from functions_framework.cli import cli
from functions_framework._cli import _cli


@pytest.fixture
Expand All @@ -30,13 +30,13 @@ def run():
@pytest.fixture
def create_app(monkeypatch, run):
create_app = pretend.call_recorder(lambda *a, **kw: pretend.stub(run=run))
monkeypatch.setattr(functions_framework.cli, "create_app", create_app)
monkeypatch.setattr(functions_framework._cli, "create_app", create_app)
return create_app


def test_cli_no_arguments():
runner = CliRunner()
result = runner.invoke(cli)
result = runner.invoke(_cli)

assert result.exit_code == 2
assert "Missing option '--target'" in result.output
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_cli_no_arguments():
)
def test_cli_arguments(create_app, run, args, env, create_app_calls, run_calls):
runner = CliRunner(env=env)
result = runner.invoke(cli, args)
result = runner.invoke(_cli, args)

assert result.exit_code == 0
assert create_app.calls == create_app_calls
Expand Down
0