-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
207 additions
and
12 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
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
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,30 @@ | ||
from pathlib import Path | ||
|
||
from cappa.testing import CommandRunner | ||
|
||
|
||
def test_htmx_download(runner: CommandRunner): | ||
runner.invoke("htmx") | ||
assert Path("htmx.min.js").exists() | ||
|
||
|
||
def test_htmx_download_with_version(runner: CommandRunner): | ||
runner.invoke("htmx", "latest") | ||
assert Path("htmx.min.js").exists() | ||
|
||
|
||
def test_htmx_download_with_specific_version(runner: CommandRunner): | ||
runner.invoke("htmx", "1.8.0") | ||
assert Path("htmx.min.js").exists() | ||
|
||
|
||
def test_htmx_download_to_output_dir(runner: CommandRunner): | ||
output = Path("htmx/vendors") | ||
runner.invoke("htmx", "-o", str(output.resolve())) | ||
assert (output / "htmx.min.js").exists() | ||
|
||
|
||
def test_htmx_download_to_output_file(runner: CommandRunner): | ||
output = Path("htmx/vendors/htmx.js") | ||
runner.invoke("htmx", "-o", str(output.resolve())) | ||
assert output.exists() |
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,26 @@ | ||
from pathlib import Path | ||
|
||
from cappa.testing import CommandRunner | ||
|
||
|
||
def test_htmx_ext_download(runner: CommandRunner): | ||
runner.invoke("htmx-ext", "sse") | ||
assert Path("sse.js").exists() | ||
|
||
|
||
# def test_htmx_ext_list_extensions(runner: CommandRunner): | ||
# result = runner.invoke("htmx-ext") | ||
# assert result.strip() != "" | ||
# assert "sse" in result | ||
|
||
|
||
def test_htmx_ext_download_to_output_dir(runner: CommandRunner): | ||
output = Path("htmx/vendors/extensions") | ||
runner.invoke("htmx-ext", "sse", "-o", str(output.resolve())) | ||
assert (output / "sse.js").exists() | ||
|
||
|
||
def test_htmx_ext_download_to_output_file(runner: CommandRunner): | ||
output = Path("htmx/vendors/extensions/sse.js") | ||
runner.invoke("htmx-ext", "sse", "-o", str(output.resolve())) | ||
assert output.exists() |
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,21 @@ | ||
from pathlib import Path | ||
|
||
from cappa.testing import CommandRunner | ||
from falco.commands.install_crud_utils import DEFAULT_INSTALL_PATH | ||
|
||
|
||
def test_install_crud_utils(runner: CommandRunner): | ||
runner.invoke("install-crud-utils") | ||
assert Path(DEFAULT_INSTALL_PATH).exists() | ||
|
||
|
||
def test_install_crud_utils_to_output_dir(runner: CommandRunner): | ||
output = Path("core") | ||
runner.invoke("install-crud-utils", "-o", str(output.resolve())) | ||
assert (output / "utils.py").exists | ||
|
||
|
||
def test_install_crud_utils_to_output_file(runner: CommandRunner): | ||
output = Path("core/utils.py") | ||
runner.invoke("install-crud-utils", "-o", str(output.resolve())) | ||
assert output.exists() |
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,82 @@ | ||
from pathlib import Path | ||
|
||
from cappa.testing import CommandRunner | ||
|
||
|
||
def test_sync_dotenv(runner: CommandRunner): | ||
runner.invoke("sync-dotenv") | ||
env_file = Path(".env") | ||
env_template_file = Path(".env.template") | ||
assert env_file.exists() | ||
assert env_template_file.exists() | ||
assert "DJANGO_DEBUG=True" in env_file.read_text() | ||
assert "DJANGO_DEBUG=" in env_template_file.read_text() | ||
|
||
|
||
def test_sync_dotenv_update_files(runner: CommandRunner): | ||
env_file = Path(".env") | ||
env_template_file = Path(".env.template") | ||
env_file.write_text("ANOTHER_SPECIAL_ENV=True") | ||
env_template_file.write_text("SPECIAL_ENV=") | ||
runner.invoke("sync-dotenv") | ||
assert "SPECIAL_ENV=" in env_file.read_text() | ||
assert "ANOTHER_SPECIAL_ENV=" in env_template_file.read_text() | ||
|
||
|
||
def test_sync_dotenv_priority(runner: CommandRunner): | ||
env_file = Path(".env") | ||
env_template_file = Path(".env.template") | ||
env_file.write_text("SPECIAL_ENV=True") | ||
env_template_file.write_text("SPECIAL_ENV=") | ||
runner.invoke("sync-dotenv") | ||
assert "SPECIAL_ENV=True" in env_file.read_text() | ||
|
||
|
||
# TODO: test fill missing | ||
|
||
|
||
# | ||
# def test_write_env_with_template(tmp_path: Path): | ||
# env_template = tmp_path / ".env.template" | ||
# env_template.write_text("DJANGO_SPECIAL_KEY=") | ||
# result = runner.invoke(cli, ["write-env"]) | ||
# | ||
# env_file_content = dotenv_values(".env") | ||
# | ||
# assert "SUCCESS" in result.output | ||
# assert "DJANGO_SPECIAL_KEY" in env_file_content | ||
# | ||
# | ||
# def test_write_env_to_output(tmp_path: Path): | ||
# result = runner.invoke(cli, ["write-env", "-o", "output.env"]) | ||
# output_env = tmp_path / "output.env" | ||
# | ||
# output_env_file_content = dotenv_values(output_env) | ||
# | ||
# assert "SUCCESS" in result.output | ||
# assert output_env.exists() | ||
# assert "DJANGO_SECRET_KEY" in output_env_file_content | ||
# | ||
# | ||
# def test_write_env_priority_order(tmp_path: Path): | ||
# original_env = tmp_path / ".env" | ||
# original_env.write_text("DJANGO_SPECIAL_KEY=my_special_key") | ||
# | ||
# env_template = tmp_path / ".env.template" | ||
# env_template.write_text("DJANGO_SPECIAL_KEY=") | ||
# | ||
# result = runner.invoke(cli, ["write-env"]) | ||
# | ||
# env_file_content = dotenv_values(".env") | ||
# | ||
# assert "SUCCESS" in result.output | ||
# assert "DJANGO_SECRET_KEY" in env_file_content | ||
# assert env_file_content["DJANGO_SPECIAL_KEY"] == "my_special_key" | ||
# | ||
# | ||
# def test_write_env_postgres_pass(tmp_path: Path): | ||
# runner.invoke(cli, ["write-env", "-p"], input="password") | ||
# | ||
# env_file_content = dotenv_values(".env") | ||
# | ||
# assert "password" in env_file_content["DATABASE_URL"] |
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
import os | ||
import subprocess | ||
|
||
import pytest | ||
from cappa.testing import CommandRunner | ||
from falco.__main__ import Falco | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def change_test_dir(monkeypatch, tmp_path): | ||
monkeypatch.chdir(tmp_path) | ||
|
||
|
||
@pytest.fixture | ||
def runner(): | ||
return CommandRunner(Falco) | ||
|
||
|
||
@pytest.fixture | ||
def django_project(tmp_path): | ||
project_dir = tmp_path / "myproject" | ||
subprocess.run(["django-admin", "startproject", "myproject", str(project_dir)], check=True) | ||
os.chdir(project_dir) | ||
|
||
# Create a new Django app | ||
subprocess.run(["python", "manage.py", "startapp", "myapp"], check=True) | ||
|
||
# Create a basic model in the app | ||
model_code = """ | ||
from django.db import models | ||
class MyModel(models.Model): | ||
field1 = models.CharField(max_length=200) | ||
field2 = models.IntegerField() | ||
""" | ||
(project_dir / "myapp" / "models.py").write_text(model_code) | ||
|
||
yield project_dir | ||
os.chdir(tmp_path) |