From db0c8394c6421af1a6139f99f335331a4d84f05e Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 12:18:40 +0100 Subject: [PATCH 01/13] updated the path to webdriver in environment.py --- features/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/environment.py b/features/environment.py index 9b5cf82..e0d6b4f 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,7 +1,7 @@ from selenium import webdriver def before_all(context): - context.browser = webdriver.Chrome(r"C:\Users\Admin\Desktop\lbg\webdrivers\chromedriver.exe") + context.browser = webdriver.Chrome(r"C:\Users\Admin\Desktop\LBG7\LBG-Python-API\webdrivers\chromedriver.exe") context.browser.maximize_window() def after_all(context): From e15659b12dd54133046700e63f3cec3731a3139b Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 12:28:00 +0100 Subject: [PATCH 02/13] added assertion to test_create_post_request_status --- lbg.test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lbg.test.py b/lbg.test.py index 3271dc0..184e086 100644 --- a/lbg.test.py +++ b/lbg.test.py @@ -35,6 +35,7 @@ def test_create_post_request_status(self): Create (Post) request. Note. API will need to be running(!) """ response = requests.post(BASE_URL + '/create', json = {'name': 'Tool', 'description': 'Hammer', 'price': 10.5}) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) @unittest.skip("Skip this test for now using this decorator...") def test_create_post_request_type(self): From c051095bddffb546d5fec8c8923f08f55462736a Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 12:31:47 +0100 Subject: [PATCH 03/13] Revert "added assertion to test_create_post_request_status" This reverts commit e15659b12dd54133046700e63f3cec3731a3139b. --- lbg.test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lbg.test.py b/lbg.test.py index 184e086..3271dc0 100644 --- a/lbg.test.py +++ b/lbg.test.py @@ -35,7 +35,6 @@ def test_create_post_request_status(self): Create (Post) request. Note. API will need to be running(!) """ response = requests.post(BASE_URL + '/create', json = {'name': 'Tool', 'description': 'Hammer', 'price': 10.5}) - self.assertEqual(response.status_code, status.HTTP_201_CREATED) @unittest.skip("Skip this test for now using this decorator...") def test_create_post_request_type(self): From 054a57b5cb6050c02d1c0cb8c0757ef450146fc3 Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 12:42:45 +0100 Subject: [PATCH 04/13] created a README.md file in documentation --- documentation/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 documentation/README.md diff --git a/documentation/README.md b/documentation/README.md new file mode 100644 index 0000000..4686c4b --- /dev/null +++ b/documentation/README.md @@ -0,0 +1,3 @@ +# DOCUMENTATION FOR SPRINT 1 + +This is our documentation. \ No newline at end of file From 7ec30c7c31a0cdb64127cbfc6e1b1df1d0c3d0d6 Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 14:10:19 +0100 Subject: [PATCH 05/13] added example unit test to README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 139ccb3..b776bfa 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,18 @@ In a new terminal window use the command ~~~ bash behave .\features\restapp.feature -~~~ \ No newline at end of file +~~~ + +### Example Tests + +#### Unit + +There are unit tests included with this project, we are testing the item builder for the object that it returns. + +```python +def test_item_builder_data(self): + expected = {'name': 'Tool', 'description': 'Hammer', 'price': 10.5, '_id': 99} + self.assertEqual(item_builder("Tool", "Hammer", 10.50, 99), expected) +``` + +If we test the builder and input a name of "Tool", a description of "Hammer", a price of "10.5" and an _id of "99" we can expect and object to be created that matches this format. \ No newline at end of file From 419c2a0a16924607ab66bfe338b8d3ce6164d8a7 Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 14:16:09 +0100 Subject: [PATCH 06/13] added example integration test to README.md --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b776bfa..05148cf 100644 --- a/README.md +++ b/README.md @@ -105,4 +105,19 @@ def test_item_builder_data(self): self.assertEqual(item_builder("Tool", "Hammer", 10.50, 99), expected) ``` -If we test the builder and input a name of "Tool", a description of "Hammer", a price of "10.5" and an _id of "99" we can expect and object to be created that matches this format. \ No newline at end of file +If we test the builder and input a name of "Tool", a description of "Hammer", a price of "10.5" and an _id of "99" we can expect and object to be created that matches this format. + +#### Integration + +An example integration test is included in the project. + +For integration tests we can test the RESTful endpoints. + +```python + def test_create_post_request_status(self): + response = requests.post(BASE_URL + '/create', json = {'name': 'Tool', 'description': 'Hammer', 'price': 10.5}) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) +``` + +If we test the **Create** endpoint by sending a request with a method of `POST` and a path of `/create` we should expect the response to be... +Status code: 201, Status text: Created \ No newline at end of file From faf8d9cff9e221ad33acb4b68ad0af537c7ce22f Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 14:24:36 +0100 Subject: [PATCH 07/13] added example user acceptance test / system black-box test to README.md --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 05148cf..7f8c015 100644 --- a/README.md +++ b/README.md @@ -120,4 +120,28 @@ For integration tests we can test the RESTful endpoints. ``` If we test the **Create** endpoint by sending a request with a method of `POST` and a path of `/create` we should expect the response to be... -Status code: 201, Status text: Created \ No newline at end of file +Status code: 201, Status text: Created + +#### User Acceptance Testing + +This is similar to a 'black-box' system test as we are testing the front-end with no knowledge of the back-end. + +An example user acceptance test is included with this project. + +```gherkin +Scenario Outline: User adding a new item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item name "", description "", and price "" into the CREATE section + And The user clicks the POST button + Then The READ ALL section will populate with JSON containing _id "<_id>", name "", description "", and price "" + Examples: + | name | description | price | _id | + | Test Name | Test Description | 9.99 | 1 | +``` + +A user story has been used to create a behaviour driven test for the system. + +**Given** that a user can access the front-end of the application +**When** they input correct details for an item +**And** they submit those details +**Then** the item is created and added to the database \ No newline at end of file From 0fea1f884ca8ee91f60f361f0b8bf3f1e4a99643 Mon Sep 17 00:00:00 2001 From: CameronGuthrie Date: Fri, 9 Sep 2022 14:58:28 +0100 Subject: [PATCH 08/13] added steps to feature file for user acceptance testing --- features/environment.py | 2 +- features/restapp.feature | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/features/environment.py b/features/environment.py index e0d6b4f..926864f 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,7 +1,7 @@ from selenium import webdriver def before_all(context): - context.browser = webdriver.Chrome(r"C:\Users\Admin\Desktop\LBG7\LBG-Python-API\webdrivers\chromedriver.exe") + context.browser = webdriver.Chrome(r"C:\Users\Admin\LBG-Python-API\webdrivers\chromedriver.exe") context.browser.maximize_window() def after_all(context): diff --git a/features/restapp.feature b/features/restapp.feature index 2e45e67..5678c33 100644 --- a/features/restapp.feature +++ b/features/restapp.feature @@ -8,3 +8,34 @@ Feature: Testing the REST application Examples: | name | description | price | _id | | Test Name | Test Description | 9.99 | 1 | + + Scenario Outline: User reading one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" + Examples: + | name | description | price | _id | + | Test Name | Test Description | 9.99 | 1 | + + Scenario Outline: User updating one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>", name "", description "", and price "" into the UPDATE section + And The user clicks the PUT button + And The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" + Examples: + | name | description | price | _id | + | Updated Name | Updated Description | 99.99 | 1 | + + Scenario Outline: User deleting one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>" into the DELETE section + And The user clicks the DELETE button + And The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will be empty + Examples: + | _id | + | 1 | From a8682b182b048532c2bb58c29e9f201197ea3d36 Mon Sep 17 00:00:00 2001 From: kgkrishnaa Date: Thu, 1 Dec 2022 09:29:01 +0000 Subject: [PATCH 09/13] Amended by Gopal --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7f8c015..8a3a832 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +# I wish i learnt a bit more about python :-) # REST API starter This application is the start point for Sprint 1 of the Lloyds Bank Group Modern Engineering Bootcamp Project Specification. From 9637f82c4d0c466a3a46ef7ba24e0783cc841a53 Mon Sep 17 00:00:00 2001 From: kgkrishnaa Date: Thu, 1 Dec 2022 09:31:00 +0000 Subject: [PATCH 10/13] Revert "added steps to feature file for user acceptance testing" This reverts commit 0fea1f884ca8ee91f60f361f0b8bf3f1e4a99643. --- features/environment.py | 2 +- features/restapp.feature | 31 ------------------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/features/environment.py b/features/environment.py index 926864f..e0d6b4f 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,7 +1,7 @@ from selenium import webdriver def before_all(context): - context.browser = webdriver.Chrome(r"C:\Users\Admin\LBG-Python-API\webdrivers\chromedriver.exe") + context.browser = webdriver.Chrome(r"C:\Users\Admin\Desktop\LBG7\LBG-Python-API\webdrivers\chromedriver.exe") context.browser.maximize_window() def after_all(context): diff --git a/features/restapp.feature b/features/restapp.feature index 5678c33..2e45e67 100644 --- a/features/restapp.feature +++ b/features/restapp.feature @@ -8,34 +8,3 @@ Feature: Testing the REST application Examples: | name | description | price | _id | | Test Name | Test Description | 9.99 | 1 | - - Scenario Outline: User reading one item successfully - Given That a user is on the url "http://localhost:8080/index.html" - When The user enters the item _id "<_id>" into the GET ONE section - And The user clicks the GET One button - Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" - Examples: - | name | description | price | _id | - | Test Name | Test Description | 9.99 | 1 | - - Scenario Outline: User updating one item successfully - Given That a user is on the url "http://localhost:8080/index.html" - When The user enters the item _id "<_id>", name "", description "", and price "" into the UPDATE section - And The user clicks the PUT button - And The user enters the item _id "<_id>" into the GET ONE section - And The user clicks the GET One button - Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" - Examples: - | name | description | price | _id | - | Updated Name | Updated Description | 99.99 | 1 | - - Scenario Outline: User deleting one item successfully - Given That a user is on the url "http://localhost:8080/index.html" - When The user enters the item _id "<_id>" into the DELETE section - And The user clicks the DELETE button - And The user enters the item _id "<_id>" into the GET ONE section - And The user clicks the GET One button - Then The READ ONE section will be empty - Examples: - | _id | - | 1 | From bad0e3696acb846ec25ab6c5919e188d06064687 Mon Sep 17 00:00:00 2001 From: kgkrishnaa Date: Thu, 1 Dec 2022 09:32:11 +0000 Subject: [PATCH 11/13] Revert "Revert "added steps to feature file for user acceptance testing"" This reverts commit 9637f82c4d0c466a3a46ef7ba24e0783cc841a53. --- features/environment.py | 2 +- features/restapp.feature | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/features/environment.py b/features/environment.py index e0d6b4f..926864f 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,7 +1,7 @@ from selenium import webdriver def before_all(context): - context.browser = webdriver.Chrome(r"C:\Users\Admin\Desktop\LBG7\LBG-Python-API\webdrivers\chromedriver.exe") + context.browser = webdriver.Chrome(r"C:\Users\Admin\LBG-Python-API\webdrivers\chromedriver.exe") context.browser.maximize_window() def after_all(context): diff --git a/features/restapp.feature b/features/restapp.feature index 2e45e67..5678c33 100644 --- a/features/restapp.feature +++ b/features/restapp.feature @@ -8,3 +8,34 @@ Feature: Testing the REST application Examples: | name | description | price | _id | | Test Name | Test Description | 9.99 | 1 | + + Scenario Outline: User reading one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" + Examples: + | name | description | price | _id | + | Test Name | Test Description | 9.99 | 1 | + + Scenario Outline: User updating one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>", name "", description "", and price "" into the UPDATE section + And The user clicks the PUT button + And The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will populate with JSON containing _id "<_id>", name "", description "", and price "" + Examples: + | name | description | price | _id | + | Updated Name | Updated Description | 99.99 | 1 | + + Scenario Outline: User deleting one item successfully + Given That a user is on the url "http://localhost:8080/index.html" + When The user enters the item _id "<_id>" into the DELETE section + And The user clicks the DELETE button + And The user enters the item _id "<_id>" into the GET ONE section + And The user clicks the GET One button + Then The READ ONE section will be empty + Examples: + | _id | + | 1 | From bf66d34b9f3ab61a13b78e2c90e843c281aa97e6 Mon Sep 17 00:00:00 2001 From: kgkrishnaa Date: Thu, 1 Dec 2022 09:32:40 +0000 Subject: [PATCH 12/13] Revert "Amended by Gopal" This reverts commit a8682b182b048532c2bb58c29e9f201197ea3d36. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8a3a832..7f8c015 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -# I wish i learnt a bit more about python :-) # REST API starter This application is the start point for Sprint 1 of the Lloyds Bank Group Modern Engineering Bootcamp Project Specification. From f3098d3b18fddcabd4754d6b44ca2031f73e428f Mon Sep 17 00:00:00 2001 From: kgkrishnaa Date: Thu, 1 Dec 2022 09:47:51 +0000 Subject: [PATCH 13/13] Gopals new file added in feature branch --- fb.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 fb.md diff --git a/fb.md b/fb.md new file mode 100644 index 0000000..e366f03 --- /dev/null +++ b/fb.md @@ -0,0 +1 @@ +#This is a new file added to the feature branch