From b72cf49f1c8f7469f20e25141d39eea30bf3e9eb Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 06:24:41 +0300 Subject: [PATCH 01/24] Create config.yml --- config.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 config.yml diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..bffa8bf --- /dev/null +++ b/config.yml @@ -0,0 +1,19 @@ +version: 2.1 +orbs: + gcp-gcr: circleci/gcp-gcr@0.6.1 + cloudrun: circleci/gcp-cloud-run@1.0.0 +jobs: + build_test: + docker: + - image: circleci/python:3.7.4 + steps: + - checkout + - run: + name: Install Python Dependencies + command: | + echo 'export PATH=~$PATH:~/.local/bin' >> $BASH_ENV && source $BASH_ENV + pip install --user -r requirements.txt + - run: + name: Run Tests + command: | + pytest From ee21f1933d7c501a5819fb4e6d4726adb1310226 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 06:51:13 +0300 Subject: [PATCH 02/24] Update config.yml --- config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.yml b/config.yml index bffa8bf..c6a680f 100644 --- a/config.yml +++ b/config.yml @@ -17,3 +17,5 @@ jobs: name: Run Tests command: | pytest + + #Tests From 0b083d36b280ec4796c00b2e9d5627be71b66d01 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 06:51:47 +0300 Subject: [PATCH 03/24] Update config.yml --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index c6a680f..249feb3 100644 --- a/config.yml +++ b/config.yml @@ -16,6 +16,6 @@ jobs: - run: name: Run Tests command: | - pytest + pytests #Tests From 732ed141df3d22c04b126a6c66e2daa2414730db Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 06:53:04 +0300 Subject: [PATCH 04/24] Update config.yml --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 249feb3..c6a680f 100644 --- a/config.yml +++ b/config.yml @@ -16,6 +16,6 @@ jobs: - run: name: Run Tests command: | - pytests + pytest #Tests From 3ebeba1bf825d437dd679aca6351d1a67d5ca6d8 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 06:55:39 +0300 Subject: [PATCH 05/24] Create test --- test | 1 + 1 file changed, 1 insertion(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 0000000..d4b0b05 --- /dev/null +++ b/test @@ -0,0 +1 @@ +To simulate a trigger From a3ddff2c8a786c51e56e42c665ae79ac047ffd76 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 07:05:52 +0300 Subject: [PATCH 06/24] Rename config.yml to .circleci/config.yml --- config.yml => .circleci/config.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config.yml => .circleci/config.yml (100%) diff --git a/config.yml b/.circleci/config.yml similarity index 100% rename from config.yml rename to .circleci/config.yml From 6ee93b41d4ec68c94b5a09c6927440e15fc0528f Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 07:09:03 +0300 Subject: [PATCH 07/24] Update config.yml --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index c6a680f..026432e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,5 +17,10 @@ jobs: name: Run Tests command: | pytest +workflows: + build_test_deploy: + jobs: + - build_test + #Tests From 130a4c03c9d228f2bdd407892050125c02d9ab5a Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:11:16 +0300 Subject: [PATCH 08/24] Update requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5a4a2b9..d037089 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ flask -python-dotenv \ No newline at end of file +python-dotenv +pytest From fa9ae4702af432e82fb0592e7f473e3c0dbf5802 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:25:49 +0300 Subject: [PATCH 09/24] Update and rename test to test_app,py --- test | 1 - test_app,py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) delete mode 100644 test create mode 100644 test_app,py diff --git a/test b/test deleted file mode 100644 index d4b0b05..0000000 --- a/test +++ /dev/null @@ -1 +0,0 @@ -To simulate a trigger diff --git a/test_app,py b/test_app,py new file mode 100644 index 0000000..941c338 --- /dev/null +++ b/test_app,py @@ -0,0 +1,30 @@ +import pytest +from flask import Flask +from app_service import AppService + +@pytest.fixture +def app(): + app = Flask(__name__) + app.config['TESTING'] = True + return app + +@pytest.fixture +def client(app): + return app.test_client() + +def test_home_route(client): + response = client.get('/') + assert response.status_code == 200 + assert b"App Works!!!" in response.data + +def test_get_tasks(client): + appService = AppService() + # Assuming you have a method in AppService to return tasks + expected_response = appService.get_tasks() + + response = client.get('/api/tasks') + assert response.status_code == 200 + assert response.get_json() == expected_response + +# Similarly, write tests for create_task, update_task, and delete_task routes +# Make sure to test both success and error cases for each route. From 0a135445ecde8a458094db173a19000f9b7d0b9e Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:28:00 +0300 Subject: [PATCH 10/24] Create test_app,py --- .circleci/test_app,py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .circleci/test_app,py diff --git a/.circleci/test_app,py b/.circleci/test_app,py new file mode 100644 index 0000000..941c338 --- /dev/null +++ b/.circleci/test_app,py @@ -0,0 +1,30 @@ +import pytest +from flask import Flask +from app_service import AppService + +@pytest.fixture +def app(): + app = Flask(__name__) + app.config['TESTING'] = True + return app + +@pytest.fixture +def client(app): + return app.test_client() + +def test_home_route(client): + response = client.get('/') + assert response.status_code == 200 + assert b"App Works!!!" in response.data + +def test_get_tasks(client): + appService = AppService() + # Assuming you have a method in AppService to return tasks + expected_response = appService.get_tasks() + + response = client.get('/api/tasks') + assert response.status_code == 200 + assert response.get_json() == expected_response + +# Similarly, write tests for create_task, update_task, and delete_task routes +# Make sure to test both success and error cases for each route. From 3d4fd6b604cdd4d7509de22dd9d5436b42437135 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:45:33 +0300 Subject: [PATCH 11/24] Rename test_app,py to test_app.py --- test_app,py => test_app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test_app,py => test_app.py (100%) diff --git a/test_app,py b/test_app.py similarity index 100% rename from test_app,py rename to test_app.py From 776d73507705ce0cb22c8a61aa7176370257f13b Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:45:49 +0300 Subject: [PATCH 12/24] Rename test_app,py to test_app.py --- .circleci/{test_app,py => test_app.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .circleci/{test_app,py => test_app.py} (100%) diff --git a/.circleci/test_app,py b/.circleci/test_app.py similarity index 100% rename from .circleci/test_app,py rename to .circleci/test_app.py From 9a77fd971223b1abac1e7bb30b7b8f4997708e47 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:51:11 +0300 Subject: [PATCH 13/24] Delete .circleci/test_app.py --- .circleci/test_app.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .circleci/test_app.py diff --git a/.circleci/test_app.py b/.circleci/test_app.py deleted file mode 100644 index 941c338..0000000 --- a/.circleci/test_app.py +++ /dev/null @@ -1,30 +0,0 @@ -import pytest -from flask import Flask -from app_service import AppService - -@pytest.fixture -def app(): - app = Flask(__name__) - app.config['TESTING'] = True - return app - -@pytest.fixture -def client(app): - return app.test_client() - -def test_home_route(client): - response = client.get('/') - assert response.status_code == 200 - assert b"App Works!!!" in response.data - -def test_get_tasks(client): - appService = AppService() - # Assuming you have a method in AppService to return tasks - expected_response = appService.get_tasks() - - response = client.get('/api/tasks') - assert response.status_code == 200 - assert response.get_json() == expected_response - -# Similarly, write tests for create_task, update_task, and delete_task routes -# Make sure to test both success and error cases for each route. From 8a1be2a22a7ce0c0c3d4b082f0e8bb9cb3535e95 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:57:38 +0300 Subject: [PATCH 14/24] Update test_app.py --- test_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_app.py b/test_app.py index 941c338..a34f3c5 100644 --- a/test_app.py +++ b/test_app.py @@ -20,7 +20,7 @@ def test_home_route(client): def test_get_tasks(client): appService = AppService() # Assuming you have a method in AppService to return tasks - expected_response = appService.get_tasks() + expected_response = client.get('/api/tasks') response = client.get('/api/tasks') assert response.status_code == 200 From 816bb518917fd3c767b5de8c774d06355c7b058e Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 09:11:42 +0300 Subject: [PATCH 15/24] Update test_app.py --- test_app.py | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/test_app.py b/test_app.py index a34f3c5..a667424 100644 --- a/test_app.py +++ b/test_app.py @@ -19,12 +19,45 @@ def test_home_route(client): def test_get_tasks(client): appService = AppService() - # Assuming you have a method in AppService to return tasks - expected_response = client.get('/api/tasks') + expected_response = appService.get_tasks() response = client.get('/api/tasks') assert response.status_code == 200 assert response.get_json() == expected_response -# Similarly, write tests for create_task, update_task, and delete_task routes -# Make sure to test both success and error cases for each route. +def test_create_task(client): + appService = AppService() + new_task = { + 'id': 4, + 'name': 'task4', + 'description': 'This is task 4' + } + expected_response = appService.create_task(new_task) + + response = client.post('/api/task', json=new_task) + assert response.status_code == 200 + assert response.get_json() == expected_response + +# Similarly, write tests for update_task and delete_task routes + +def test_update_task(client): + appService = AppService() + updated_task = { + 'id': 1, + 'name': 'task1_updated', + 'description': 'This is the updated task 1' + } + expected_response = appService.update_task(updated_task) + + response = client.put('/api/task', json=updated_task) + assert response.status_code == 200 + assert response.get_json() == expected_response + +def test_delete_task(client): + appService = AppService() + task_id_to_delete = 1 + expected_response = appService.delete_task(task_id_to_delete) + + response = client.delete(f'/api/task/{task_id_to_delete}') + assert response.status_code == 200 + assert response.get_json() == expected_response From af1b00b83c9b644c85ca756808cb669deecf5781 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:10:34 +0300 Subject: [PATCH 16/24] Rename app.py to .circleci/app.py --- app.py => .circleci/app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app.py => .circleci/app.py (100%) diff --git a/app.py b/.circleci/app.py similarity index 100% rename from app.py rename to .circleci/app.py From 0860183ded39857b5ea36ff124621462d646c62f Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:11:12 +0300 Subject: [PATCH 17/24] Rename app_service.py to .circleci/app_service.py --- app_service.py => .circleci/app_service.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app_service.py => .circleci/app_service.py (100%) diff --git a/app_service.py b/.circleci/app_service.py similarity index 100% rename from app_service.py rename to .circleci/app_service.py From a9e86335d6684e36a0b3703df573b5b09c0cefcb Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:12:45 +0300 Subject: [PATCH 18/24] Rename test_app.py to .circleci/test_app.py --- test_app.py => .circleci/test_app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test_app.py => .circleci/test_app.py (100%) diff --git a/test_app.py b/.circleci/test_app.py similarity index 100% rename from test_app.py rename to .circleci/test_app.py From db283ad881cc8d385933e4939fb5dc7f634fb1aa Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:18:06 +0300 Subject: [PATCH 19/24] Rename test_app.py to test_app.py --- {.circleci => myapp}/test_app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.circleci => myapp}/test_app.py (100%) diff --git a/.circleci/test_app.py b/myapp/test_app.py similarity index 100% rename from .circleci/test_app.py rename to myapp/test_app.py From f833039cad8d4056021309bd3a5e2f4c8ccfc898 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:19:14 +0300 Subject: [PATCH 20/24] Rename myapp/test_app.py to test_app.py --- myapp/test_app.py => test_app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename myapp/test_app.py => test_app.py (100%) diff --git a/myapp/test_app.py b/test_app.py similarity index 100% rename from myapp/test_app.py rename to test_app.py From c01f0ddbdb9344192b7cd64a9f9f0ef8609e421f Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:19:36 +0300 Subject: [PATCH 21/24] Rename .circleci/app_service.py to app_service.py --- .circleci/app_service.py => app_service.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .circleci/app_service.py => app_service.py (100%) diff --git a/.circleci/app_service.py b/app_service.py similarity index 100% rename from .circleci/app_service.py rename to app_service.py From 2f94d13db77e1543e3d45defc23a4b4b112a9ee7 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:20:02 +0300 Subject: [PATCH 22/24] Rename .circleci/app.py to app.py --- .circleci/app.py => app.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .circleci/app.py => app.py (100%) diff --git a/.circleci/app.py b/app.py similarity index 100% rename from .circleci/app.py rename to app.py From e3e3d45f36ae518668921df1d9689d31edc57f9c Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Sat, 23 Sep 2023 09:56:25 +0300 Subject: [PATCH 23/24] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 026432e..c8bde6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: - run: name: Run Tests command: | - pytest + pytest test_app.py workflows: build_test_deploy: jobs: From cbcef71dc6ad04cc8adca5ebed4dec6085f93344 Mon Sep 17 00:00:00 2001 From: CloudEngineer20 <71173913+CloudEngineer20@users.noreply.github.com> Date: Sat, 23 Sep 2023 09:56:43 +0300 Subject: [PATCH 24/24] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c8bde6b..026432e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: - run: name: Run Tests command: | - pytest test_app.py + pytest workflows: build_test_deploy: jobs: