-
-
Notifications
You must be signed in to change notification settings - Fork 331
feat: add robyn-config as optional dependencies #1387
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
Open
Lehsqa
wants to merge
1
commit into
sparckles:main
Choose a base branch
from
Lehsqa:feature/robin-config-depends
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,134 @@ | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import tempfile | ||
|
|
||
| import pytest | ||
|
|
||
| _HAS_ROBYN_CONFIG = shutil.which("robyn-config") is not None | ||
|
|
||
| pytestmark = pytest.mark.skipif(not _HAS_ROBYN_CONFIG, reason="robyn-config not installed") | ||
|
|
||
|
|
||
| class TestRobynConfigCLI: | ||
| """Verify that the robyn-config CLI is accessible and functional.""" | ||
|
|
||
| def test_cli_help_exits_zero(self): | ||
| """robyn-config --help should exit with code 0.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "--help"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=30, | ||
| ) | ||
| assert result.returncode == 0 | ||
| assert "Usage" in result.stdout | ||
|
|
||
| def test_cli_create_help(self): | ||
| """robyn-config create --help should list available options.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "create", "--help"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=30, | ||
| ) | ||
| assert result.returncode == 0 | ||
| assert "create" in result.stdout.lower() or "Usage" in result.stdout | ||
|
|
||
| def test_cli_add_help(self): | ||
| """robyn-config add --help should list available options.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "add", "--help"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=30, | ||
| ) | ||
| assert result.returncode == 0 | ||
|
|
||
|
|
||
| class TestRobynConfigScaffolding: | ||
| """Integration tests for project scaffolding.""" | ||
|
|
||
| @pytest.fixture | ||
| def temp_dir(self): | ||
| """Create a temporary directory for scaffolding tests.""" | ||
| tmp = tempfile.mkdtemp(prefix="robyn_config_test_") | ||
| yield tmp | ||
| shutil.rmtree(tmp, ignore_errors=True) | ||
|
|
||
| @pytest.fixture | ||
| def scaffolded_project(self): | ||
| """Create a scaffolded project for tests that build on top of it.""" | ||
| tmp = tempfile.mkdtemp(prefix="robyn_config_scaffolded_") | ||
| subprocess.run( | ||
| ["robyn-config", "create", "testproj", tmp, "--design", "ddd", "--orm", "sqlalchemy"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=60, | ||
| ) | ||
| yield tmp | ||
| shutil.rmtree(tmp, ignore_errors=True) | ||
|
|
||
| @pytest.mark.parametrize("design", ["ddd", "mvc"]) | ||
| @pytest.mark.parametrize("orm", ["sqlalchemy", "tortoise"]) | ||
| def test_create_project_scaffold(self, temp_dir, design, orm): | ||
| """robyn-config create should scaffold a valid project structure.""" | ||
| project_name = f"test_project_{design}_{orm}" | ||
|
|
||
| result = subprocess.run( | ||
| ["robyn-config", "create", project_name, temp_dir, "--design", design, "--orm", orm], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=60, | ||
| ) | ||
| assert result.returncode == 0, f"stderr: {result.stderr}" | ||
|
|
||
| # Verify essential files/directories exist in the scaffolded project | ||
| assert os.path.isfile(os.path.join(temp_dir, "pyproject.toml")), "pyproject.toml not found" | ||
| assert os.path.isdir(os.path.join(temp_dir, "src")), "src/ directory not found" | ||
| assert os.path.isfile(os.path.join(temp_dir, "Makefile")), "Makefile not found" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| def test_adminpanel_scaffolding(self, scaffolded_project): | ||
| """robyn-config adminpanel should add admin panel files to an existing project.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "adminpanel", scaffolded_project], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=60, | ||
| ) | ||
| assert result.returncode == 0, f"stderr: {result.stderr}" | ||
|
|
||
| # Verify admin panel files were created | ||
| adminpanel_dir = os.path.join(scaffolded_project, "src", "app", "infrastructure", "adminpanel") | ||
| assert os.path.isdir(adminpanel_dir), "adminpanel directory not created" | ||
|
|
||
| def test_adminpanel_with_custom_credentials(self, scaffolded_project): | ||
| """robyn-config adminpanel should accept custom username and password.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "adminpanel", scaffolded_project, "--username", "testadmin", "--password", "testpass"], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=60, | ||
| ) | ||
| assert result.returncode == 0, f"stderr: {result.stderr}" | ||
|
|
||
| adminpanel_dir = os.path.join(scaffolded_project, "src", "app", "infrastructure", "adminpanel") | ||
| assert os.path.isdir(adminpanel_dir), "adminpanel directory not created" | ||
|
|
||
| def test_monitoring_scaffolding(self, scaffolded_project): | ||
| """robyn-config monitoring should add monitoring pipeline to an existing project.""" | ||
| result = subprocess.run( | ||
| ["robyn-config", "monitoring", scaffolded_project], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=60, | ||
| ) | ||
| assert result.returncode == 0, f"stderr: {result.stderr}" | ||
|
|
||
| # Verify monitoring files were created | ||
| assert os.path.isfile(os.path.join(scaffolded_project, "docker-compose.monitoring.yml")), "docker-compose.monitoring.yml not found" | ||
|
|
||
| monitoring_dir = os.path.join(scaffolded_project, "compose", "monitoring") | ||
| assert os.path.isdir(monitoring_dir), "compose/monitoring directory not created" | ||
| assert os.path.isdir(os.path.join(monitoring_dir, "alloy")), "alloy config not found" | ||
| assert os.path.isdir(os.path.join(monitoring_dir, "grafana")), "grafana config not found" | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.