-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a command to serve sites using the Dockerized nginx server (#1476)
- Loading branch information
1 parent
625ac75
commit b99abf6
Showing
7 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Provide Command Line Interface functionality. | ||
""" | ||
|
||
from asyncio import sleep | ||
|
||
import click | ||
|
||
from betty.app import App | ||
from betty.cli import app_command | ||
from betty.extension.nginx import serve | ||
|
||
|
||
@click.command(help="Serve a generated site with nginx in a Docker container.") | ||
@app_command | ||
async def _serve(app: App) -> None: | ||
async with serve.DockerizedNginxServer(app) as server: | ||
await server.show() | ||
while True: | ||
await sleep(999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from aiofiles.os import makedirs | ||
from pytest_mock import MockerFixture | ||
|
||
from betty.app import App | ||
from betty.extension import Nginx | ||
from betty.extension.nginx.serve import DockerizedNginxServer | ||
from betty.tests.test_cli import run | ||
|
||
|
||
class KeyboardInterruptedDockerizedNginxServer(DockerizedNginxServer): | ||
async def start(self) -> None: | ||
raise KeyboardInterrupt() | ||
|
||
|
||
class TestServe: | ||
async def test(self, mocker: MockerFixture, new_temporary_app: App) -> None: | ||
mocker.patch( | ||
"betty.extension.nginx.serve.DockerizedNginxServer", | ||
new=KeyboardInterruptedDockerizedNginxServer, | ||
) | ||
new_temporary_app.project.configuration.extensions.enable(Nginx) | ||
await new_temporary_app.project.configuration.write() | ||
await makedirs(new_temporary_app.project.configuration.www_directory_path) | ||
run( | ||
"-c", | ||
str(new_temporary_app.project.configuration.configuration_file_path), | ||
"serve-nginx-docker", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters