From 19c9a74cc1d69aa3fb3336c4fee79cd306204a52 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 7 Jan 2020 16:33:21 -0500 Subject: [PATCH 1/3] Testing code for building search --- .../apps/bis/features/addressSearch.feature | 16 ++++++++ .../apps/bis/features/steps/addressSearch.py | 40 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 bloclink/apps/bis/features/addressSearch.feature create mode 100644 bloclink/apps/bis/features/steps/addressSearch.py diff --git a/bloclink/apps/bis/features/addressSearch.feature b/bloclink/apps/bis/features/addressSearch.feature new file mode 100644 index 0000000..31ec0e9 --- /dev/null +++ b/bloclink/apps/bis/features/addressSearch.feature @@ -0,0 +1,16 @@ +Feature: Building search + + Scenario: Load building search page + Given request method as "GET" + When user request the application URi + Then result page will include code "200" + + Scenario: Search for a valid building + Given request method as "PUT" + When user search for a valid address + Then result page will include code "200" + + Scenario: Search for an invalid building + Given request method as "PUT" + When user search for a invalid address + Then result page will include code "400" diff --git a/bloclink/apps/bis/features/steps/addressSearch.py b/bloclink/apps/bis/features/steps/addressSearch.py new file mode 100644 index 0000000..e7ed7d6 --- /dev/null +++ b/bloclink/apps/bis/features/steps/addressSearch.py @@ -0,0 +1,40 @@ +from behave import * +import requests + + +# api_endpoints = {} +# request_headers = {} +# response_texts={} +# request_bodies = {} +# api_url=None +response_codes = {} +get_url = 'http://0.0.0.0:3000/' +post_url = 'http://0.0.0.0:5410/buildings/bis/submit-building/' +headers = {} +request = { + 'method': '', +} + +@given('request method as "{method}"') +def step_impl(context, method): + request['method'] = method + +@when('user request the application URi') +def step_impl(context): + response = requests.get(url=get_url, headers={'Content-Type': 'GET'}) + response_codes[request['method']] = response.status_code + +@when('user search for a valid address') +def step_impl(context): + response = requests.put(url=post_url, json={'address': '81 Prospect Street, Staten Island, New York 10304, United States'}, headers={'Content-Type': 'PUT'}) + response_codes[request['method']] = response.status_code + +@when('user search for a invalid address') +def step_impl(context): + response = requests.put(url=post_url, json={'address': 'New Portland, Maine, United States'}, headers={'Content-Type': 'PUT'}) + response_codes[request['method']] = response.status_code + +@then('result page will include code "{code}"') +def step_impl(context, code): + assert code == str(response_codes[request['method']]) + # assert True is not False -- GitLab From 5a0eee53c2c312daad9eaa466e20bb40d1dc57d2 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 8 Jan 2020 15:40:58 -0500 Subject: [PATCH 2/3] Restructure the testing code --- .../apps/bis/features/addressSearch.feature | 31 +++++++--- .../apps/bis/features/steps/addressSearch.py | 58 ++++++++++--------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/bloclink/apps/bis/features/addressSearch.feature b/bloclink/apps/bis/features/addressSearch.feature index 31ec0e9..8c87b36 100644 --- a/bloclink/apps/bis/features/addressSearch.feature +++ b/bloclink/apps/bis/features/addressSearch.feature @@ -1,16 +1,29 @@ Feature: Building search - Scenario: Load building search page - Given request method as "GET" - When user request the application URi - Then result page will include code "200" - Scenario: Search for a valid building - Given request method as "PUT" - When user search for a valid address + Given a valid building address + | address | + | 489 Hart Street, Brooklyn, New York 11221, United States | + | 81 Prospect Street, Staten Island, New York 10304, United States | + | Oakland California Temple, 4770 Lincoln Ave, Oakland, California 94602, United States | Then result page will include code "200" + And result page will include success as "True" Scenario: Search for an invalid building - Given request method as "PUT" - When user search for a invalid address + Given an invalid building address + | address | + | Staten Island, New York, New York, United States | + | New York, New York, New York 10453, United States | + | New York, New York, United States | + | New York, New York 10453, United States | + | East New York, Brooklyn, New York, New York 11208, United States | + Then result page will include code "400" + And result page will include success as "False" + + Scenario: Search for a not covered building + Given a not covered building address + | address | + | New Jersey Motor Vehicle Commission, 481 US Route 46 W, Wayne, New Jersey 07470, United States | + | 60 East Jamaica Avenue, Valley Stream, New York 11580, United States | Then result page will include code "400" + And result page will include success as "False" diff --git a/bloclink/apps/bis/features/steps/addressSearch.py b/bloclink/apps/bis/features/steps/addressSearch.py index e7ed7d6..da73319 100644 --- a/bloclink/apps/bis/features/steps/addressSearch.py +++ b/bloclink/apps/bis/features/steps/addressSearch.py @@ -1,40 +1,42 @@ from behave import * import requests +import json -# api_endpoints = {} -# request_headers = {} -# response_texts={} -# request_bodies = {} -# api_url=None -response_codes = {} -get_url = 'http://0.0.0.0:3000/' -post_url = 'http://0.0.0.0:5410/buildings/bis/submit-building/' -headers = {} -request = { - 'method': '', -} - -@given('request method as "{method}"') -def step_impl(context, method): - request['method'] = method - -@when('user request the application URi') +endpoint = 'http://0.0.0.0:5410/buildings/bis/submit-building/' +responses = [] + +@given('a valid building address') def step_impl(context): - response = requests.get(url=get_url, headers={'Content-Type': 'GET'}) - response_codes[request['method']] = response.status_code + global responses + responses = [] + for row in context.table: + response = requests.put(url=endpoint, json={'address': row['address']}, headers={'Content-Type': 'PUT'}) + responses.append(response) -@when('user search for a valid address') +@given('an invalid building address') def step_impl(context): - response = requests.put(url=post_url, json={'address': '81 Prospect Street, Staten Island, New York 10304, United States'}, headers={'Content-Type': 'PUT'}) - response_codes[request['method']] = response.status_code + global responses + responses = [] + for row in context.table: + response = requests.put(url=endpoint, json={'address': row['address']}, headers={'Content-Type': 'PUT'}) + responses.append(response) -@when('user search for a invalid address') +@given('a not covered building address') def step_impl(context): - response = requests.put(url=post_url, json={'address': 'New Portland, Maine, United States'}, headers={'Content-Type': 'PUT'}) - response_codes[request['method']] = response.status_code + global responses + responses = [] + for row in context.table: + response = requests.put(url=endpoint, json={'address': row['address']}, headers={'Content-Type': 'PUT'}) + responses.append(response) @then('result page will include code "{code}"') def step_impl(context, code): - assert code == str(response_codes[request['method']]) - # assert True is not False + for response in responses: + assert code == str(response.status_code) + +@then('result page will include success as "{TrueOrFalse}"') +def step_impl(context, TrueOrFalse): + for response in responses: + assert TrueOrFalse == str(json.loads(response.text)['success']) + -- GitLab From eac191f5822ca8ab4de308c15855fd1b747db53c Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 9 Jan 2020 17:16:49 -0500 Subject: [PATCH 3/3] Add submit answers testing code --- .../apps/bis/features/addressSearch.feature | 29 ----- .../apps/bis/features/steps/submitAnswers.py | 26 ++++ .../{addressSearch.py => submitBuilding.py} | 0 .../apps/bis/features/submitAnswers.feature | 113 ++++++++++++++++++ 4 files changed, 139 insertions(+), 29 deletions(-) delete mode 100644 bloclink/apps/bis/features/addressSearch.feature create mode 100644 bloclink/apps/bis/features/steps/submitAnswers.py rename bloclink/apps/bis/features/steps/{addressSearch.py => submitBuilding.py} (100%) create mode 100644 bloclink/apps/bis/features/submitAnswers.feature diff --git a/bloclink/apps/bis/features/addressSearch.feature b/bloclink/apps/bis/features/addressSearch.feature deleted file mode 100644 index 8c87b36..0000000 --- a/bloclink/apps/bis/features/addressSearch.feature +++ /dev/null @@ -1,29 +0,0 @@ -Feature: Building search - - Scenario: Search for a valid building - Given a valid building address - | address | - | 489 Hart Street, Brooklyn, New York 11221, United States | - | 81 Prospect Street, Staten Island, New York 10304, United States | - | Oakland California Temple, 4770 Lincoln Ave, Oakland, California 94602, United States | - Then result page will include code "200" - And result page will include success as "True" - - Scenario: Search for an invalid building - Given an invalid building address - | address | - | Staten Island, New York, New York, United States | - | New York, New York, New York 10453, United States | - | New York, New York, United States | - | New York, New York 10453, United States | - | East New York, Brooklyn, New York, New York 11208, United States | - Then result page will include code "400" - And result page will include success as "False" - - Scenario: Search for a not covered building - Given a not covered building address - | address | - | New Jersey Motor Vehicle Commission, 481 US Route 46 W, Wayne, New Jersey 07470, United States | - | 60 East Jamaica Avenue, Valley Stream, New York 11580, United States | - Then result page will include code "400" - And result page will include success as "False" diff --git a/bloclink/apps/bis/features/steps/submitAnswers.py b/bloclink/apps/bis/features/steps/submitAnswers.py new file mode 100644 index 0000000..7eb8876 --- /dev/null +++ b/bloclink/apps/bis/features/steps/submitAnswers.py @@ -0,0 +1,26 @@ +from behave import * +import requests +import json + + +endpoint = 'http://0.0.0.0:5410/buildings/bis/submit-answer/' +responses = [] + +@given('valid answers') +def step_impl(context): + global responses + responses = [] + for row in context.table: + response = requests.put( + url=endpoint, + json={ + 'questionId': row['questionId'], + 'answerId': row['answerId'], + 'surveyId': row['surveyId'], + 'buildingId': row['buildingId'], + 'userId': row['userId'], + }, + headers={'Content-Type': 'PUT'} + ) + responses.append(response) + diff --git a/bloclink/apps/bis/features/steps/addressSearch.py b/bloclink/apps/bis/features/steps/submitBuilding.py similarity index 100% rename from bloclink/apps/bis/features/steps/addressSearch.py rename to bloclink/apps/bis/features/steps/submitBuilding.py diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature new file mode 100644 index 0000000..fe469fd --- /dev/null +++ b/bloclink/apps/bis/features/submitAnswers.feature @@ -0,0 +1,113 @@ +Feature: Submit answers + + @fuelTypes @newyorkcity + Scenario: Submit fuel types with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | [1] | [3] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @heatDistribution @newyorkcity + Scenario: Submit heat distribution with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | [2] | [9] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @heatingSystemAge @newyorkcity + Scenario: Submit heating system age with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | [3] | [14] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @heatingSystemReplacementPlan @newyorkcity + Scenario: Submit heating system replacement plan with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | [4] | [18] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @buildingType @newyorkcity + Scenario: Submit building type with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | [6] | [21] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @utilityBills @newyorkcity + Scenario: Submit utility bills with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["5", "8"] | [24, 25] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @comfortIssues @newyorkcity + Scenario: Submit comfort issues with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["7"] | [["27", "28", "29"]] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @financeInterest @newyorkcity + Scenario: Submit finance interest with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["9"] | [1] | 1 | 152699 | 1594 | + Then result page will include code "200" + And result page will include success as "True" + + @buildingType @oakland + Scenario: Submit building type with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["12", "13"] | [34, 40] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" + + @buildingNeeds @oakland + Scenario: Submit building needs with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["14"] | [[76, 77, 78]] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" + + @buildingChallenges @oakland + Scenario: Submit building chanllenges with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["15"] | [[87, 88, 89]] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" + + @heatingSystem @oakland + Scenario: Submit heating system with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["16"] | [101] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" + + @energyImprovementsPastYears @oakland + Scenario: Submit energy improvements past 5 years with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34"] | [2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" + + @energyImprovementsNextYears @oakland + Scenario: Submit energy improvements next years with valid answers + Given valid answers + | questionId | answerId | surveyId | buildingId | userId | + | ["35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51"] | [2,2,1,2,2,2,2,2,2,2,1,1,2,2,2,2,2] | 2 | 1189746 | 1601 | + Then result page will include code "200" + And result page will include success as "True" -- GitLab