Skip to content

Commit

Permalink
feat: Improve rosemary maek:module command
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Jun 4, 2024
1 parent 531f14a commit 8491bd2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions core/environment/host.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
from dotenv import load_dotenv

load_dotenv()


def get_host_for_testing(test_type):
Expand Down
3 changes: 1 addition & 2 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ services:
context: ../
dockerfile: docker/images/Dockerfile.dev
volumes:
- ./entrypoints/development_entrypoint.sh:/app/entrypoint.sh
- ../:/app
- /var/run/docker.sock:/var/run/docker.sock
command: [ "sh", "-c", "sh /app/entrypoint.sh" ]
command: [ "sh", "-c", "sh /app/docker/entrypoints/development_entrypoint.sh" ]
networks:
- uvlhub_network

Expand Down
3 changes: 2 additions & 1 deletion rosemary/commands/make_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def make_module(name):
'forms.py': 'blueprint_forms.py.j2',
'seeders.py': 'blueprint_seeders.py.j2',
os.path.join('templates', name, 'index.html'): 'blueprint_templates_index.html.j2',
'tests/test_unit.py': 'blueprint_tests_test_unit.py.j2'
'tests/test_unit.py': 'blueprint_tests_test_unit.py.j2',
'tests/locustfile.py': 'blueprint_tests_locustfile.py.j2'
}

# Create the necessary directories, explicitly excluding 'tests' from the creation of subfolders.
Expand Down
21 changes: 21 additions & 0 deletions rosemary/templates/blueprint_tests_locustfile.py.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from locust import HttpUser, TaskSet, task
from core.environment.host import get_host_for_locust_testing


class {{ blueprint_name | pascalcase }}Behavior(TaskSet):
def on_start(self):
self.index()

@task
def index(self):
response = self.client.get("/{{ blueprint_name }}")

if response.status_code != 200:
print(f"{{ blueprint_name | pascalcase }} index failed: {response.status_code}")


class {{ blueprint_name | pascalcase }}User(HttpUser):
tasks = [{{ blueprint_name | pascalcase }}Behavior]
min_wait = 5000
max_wait = 9000
host = get_host_for_locust_testing()

0 comments on commit 8491bd2

Please sign in to comment.