From 7970dc87727156d7a1c60f701b8f7a5ca1f7f051 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:16:40 -0700 Subject: [PATCH 1/4] look for DONE in the bigger chunk of the response --- core/agents/task_reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/agents/task_reviewer.py b/core/agents/task_reviewer.py index 7c0aa9830..f6b3999a4 100644 --- a/core/agents/task_reviewer.py +++ b/core/agents/task_reviewer.py @@ -47,7 +47,7 @@ async def review_code_changes(self) -> AgentResponse: ) llm_response: str = await llm(convo, temperature=0.7) - if "done" in llm_response.strip().lower()[-7:]: + if "done" in llm_response.strip().lower()[-20:]: return AgentResponse.done(self) else: return AgentResponse.task_review_feedback(self, llm_response) From c4455a9c76ce5de2a871b939b09aff76d9df6260 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:17:21 -0700 Subject: [PATCH 2/4] Commented out Senko's last template until we get it fixed --- core/templates/registry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index f52f89b89..a951e92e4 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -3,7 +3,7 @@ from core.log import get_logger from .node_express_mongoose import NodeExpressMongooseProjectTemplate -from .react_express import ReactExpressProjectTemplate +# from .react_express import ReactExpressProjectTemplate log = get_logger(__name__) @@ -13,11 +13,11 @@ class ProjectTemplateEnum(str, Enum): # JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name - REACT_EXPRESS = ReactExpressProjectTemplate.name + # REACT_EXPRESS = ReactExpressProjectTemplate.name PROJECT_TEMPLATES = { # JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate, - ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, + # ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, } From ac7e3b6978b341f3b93762a8400b89d60ff18d17 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:23:08 -0700 Subject: [PATCH 3/4] Formatting fix --- core/templates/registry.py | 1 + tests/templates/test_templates.py | 95 +++++++++++++++---------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index a951e92e4..db4f84e22 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -3,6 +3,7 @@ from core.log import get_logger from .node_express_mongoose import NodeExpressMongooseProjectTemplate + # from .react_express import ReactExpressProjectTemplate log = get_logger(__name__) diff --git a/tests/templates/test_templates.py b/tests/templates/test_templates.py index 25d61741a..6d27e37b7 100644 --- a/tests/templates/test_templates.py +++ b/tests/templates/test_templates.py @@ -5,54 +5,53 @@ from core.state.state_manager import StateManager from core.templates.registry import PROJECT_TEMPLATES - -@pytest.mark.asyncio -@patch("core.state.state_manager.get_config") -async def test_render_react_express_sql(mock_get_config, testmanager): - mock_get_config.return_value.fs.type = "memory" - sm = StateManager(testmanager) - pm = MagicMock(run_command=AsyncMock()) - - await sm.create_project("TestProjectName") - await sm.commit() - - TemplateClass = PROJECT_TEMPLATES["react_express"] - options = TemplateClass.options_class(db_type="sql", auth=True) - template = TemplateClass(options, sm, pm) - - assert template.options_dict == {"db_type": "sql", "auth": True} - - await template.apply() - - files = sm.file_system.list() - for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: - assert f in files - assert "api/models/user.js" not in files - - -@pytest.mark.asyncio -@patch("core.state.state_manager.get_config") -async def test_render_react_express_nosql(mock_get_config, testmanager): - mock_get_config.return_value.fs.type = "memory" - sm = StateManager(testmanager) - pm = MagicMock(run_command=AsyncMock()) - - await sm.create_project("TestProjectName") - await sm.commit() - - TemplateClass = PROJECT_TEMPLATES["react_express"] - options = TemplateClass.options_class(db_type="nosql", auth=True) - template = TemplateClass(options, sm, pm) - - assert template.options_dict == {"db_type": "nosql", "auth": True} - - await template.apply() - - files = sm.file_system.list() - print(files) - for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: - assert f in files - assert "prisma/schema.prisma" not in files +# @pytest.mark.asyncio +# @patch("core.state.state_manager.get_config") +# async def test_render_react_express_sql(mock_get_config, testmanager): +# mock_get_config.return_value.fs.type = "memory" +# sm = StateManager(testmanager) +# pm = MagicMock(run_command=AsyncMock()) +# +# await sm.create_project("TestProjectName") +# await sm.commit() +# +# TemplateClass = PROJECT_TEMPLATES["react_express"] +# options = TemplateClass.options_class(db_type="sql", auth=True) +# template = TemplateClass(options, sm, pm) +# +# assert template.options_dict == {"db_type": "sql", "auth": True} +# +# await template.apply() +# +# files = sm.file_system.list() +# for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: +# assert f in files +# assert "api/models/user.js" not in files + + +# @pytest.mark.asyncio +# @patch("core.state.state_manager.get_config") +# async def test_render_react_express_nosql(mock_get_config, testmanager): +# mock_get_config.return_value.fs.type = "memory" +# sm = StateManager(testmanager) +# pm = MagicMock(run_command=AsyncMock()) +# +# await sm.create_project("TestProjectName") +# await sm.commit() +# +# TemplateClass = PROJECT_TEMPLATES["react_express"] +# options = TemplateClass.options_class(db_type="nosql", auth=True) +# template = TemplateClass(options, sm, pm) +# +# assert template.options_dict == {"db_type": "nosql", "auth": True} +# +# await template.apply() +# +# files = sm.file_system.list() +# print(files) +# for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: +# assert f in files +# assert "prisma/schema.prisma" not in files @pytest.mark.skip From b0e6ea72906e977522cae8b79625ae90dc1924fe Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Mon, 29 Jul 2024 10:40:50 +0200 Subject: [PATCH 4/4] skip tests instead of commenting them out --- core/templates/registry.py | 5 +- tests/templates/test_templates.py | 97 ++++++++++++++++--------------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index db4f84e22..a07a25a39 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -2,6 +2,7 @@ from core.log import get_logger +from .javascript_react import JavascriptReactProjectTemplate from .node_express_mongoose import NodeExpressMongooseProjectTemplate # from .react_express import ReactExpressProjectTemplate @@ -12,13 +13,13 @@ class ProjectTemplateEnum(str, Enum): """Choices of available project templates.""" - # JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name + JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name # REACT_EXPRESS = ReactExpressProjectTemplate.name PROJECT_TEMPLATES = { - # JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, + JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate, # ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, } diff --git a/tests/templates/test_templates.py b/tests/templates/test_templates.py index 6d27e37b7..dd21a7866 100644 --- a/tests/templates/test_templates.py +++ b/tests/templates/test_templates.py @@ -5,53 +5,56 @@ from core.state.state_manager import StateManager from core.templates.registry import PROJECT_TEMPLATES -# @pytest.mark.asyncio -# @patch("core.state.state_manager.get_config") -# async def test_render_react_express_sql(mock_get_config, testmanager): -# mock_get_config.return_value.fs.type = "memory" -# sm = StateManager(testmanager) -# pm = MagicMock(run_command=AsyncMock()) -# -# await sm.create_project("TestProjectName") -# await sm.commit() -# -# TemplateClass = PROJECT_TEMPLATES["react_express"] -# options = TemplateClass.options_class(db_type="sql", auth=True) -# template = TemplateClass(options, sm, pm) -# -# assert template.options_dict == {"db_type": "sql", "auth": True} -# -# await template.apply() -# -# files = sm.file_system.list() -# for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: -# assert f in files -# assert "api/models/user.js" not in files - - -# @pytest.mark.asyncio -# @patch("core.state.state_manager.get_config") -# async def test_render_react_express_nosql(mock_get_config, testmanager): -# mock_get_config.return_value.fs.type = "memory" -# sm = StateManager(testmanager) -# pm = MagicMock(run_command=AsyncMock()) -# -# await sm.create_project("TestProjectName") -# await sm.commit() -# -# TemplateClass = PROJECT_TEMPLATES["react_express"] -# options = TemplateClass.options_class(db_type="nosql", auth=True) -# template = TemplateClass(options, sm, pm) -# -# assert template.options_dict == {"db_type": "nosql", "auth": True} -# -# await template.apply() -# -# files = sm.file_system.list() -# print(files) -# for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: -# assert f in files -# assert "prisma/schema.prisma" not in files + +@pytest.mark.skip +@pytest.mark.asyncio +@patch("core.state.state_manager.get_config") +async def test_render_react_express_sql(mock_get_config, testmanager): + mock_get_config.return_value.fs.type = "memory" + sm = StateManager(testmanager) + pm = MagicMock(run_command=AsyncMock()) + + await sm.create_project("TestProjectName") + await sm.commit() + + TemplateClass = PROJECT_TEMPLATES["react_express"] + options = TemplateClass.options_class(db_type="sql", auth=True) + template = TemplateClass(options, sm, pm) + + assert template.options_dict == {"db_type": "sql", "auth": True} + + await template.apply() + + files = sm.file_system.list() + for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: + assert f in files + assert "api/models/user.js" not in files + + +@pytest.mark.skip +@pytest.mark.asyncio +@patch("core.state.state_manager.get_config") +async def test_render_react_express_nosql(mock_get_config, testmanager): + mock_get_config.return_value.fs.type = "memory" + sm = StateManager(testmanager) + pm = MagicMock(run_command=AsyncMock()) + + await sm.create_project("TestProjectName") + await sm.commit() + + TemplateClass = PROJECT_TEMPLATES["react_express"] + options = TemplateClass.options_class(db_type="nosql", auth=True) + template = TemplateClass(options, sm, pm) + + assert template.options_dict == {"db_type": "nosql", "auth": True} + + await template.apply() + + files = sm.file_system.list() + print(files) + for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: + assert f in files + assert "prisma/schema.prisma" not in files @pytest.mark.skip