diff --git a/bloclink/apps/bis/features/steps/submitAnswers.py b/bloclink/apps/bis/features/steps/submitAnswers.py new file mode 100644 index 0000000000000000000000000000000000000000..7eb8876aa1341acb8c973cd783f8f54e15f30f90 --- /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/submitBuilding.py b/bloclink/apps/bis/features/steps/submitBuilding.py new file mode 100644 index 0000000000000000000000000000000000000000..da733190b284d50769865ea1a5b263a30c54c86c --- /dev/null +++ b/bloclink/apps/bis/features/steps/submitBuilding.py @@ -0,0 +1,42 @@ +from behave import * +import requests +import json + + +endpoint = 'http://0.0.0.0:5410/buildings/bis/submit-building/' +responses = [] + +@given('a valid building address') +def step_impl(context): + global responses + responses = [] + for row in context.table: + response = requests.put(url=endpoint, json={'address': row['address']}, headers={'Content-Type': 'PUT'}) + responses.append(response) + +@given('an invalid building address') +def step_impl(context): + global responses + responses = [] + for row in context.table: + response = requests.put(url=endpoint, json={'address': row['address']}, headers={'Content-Type': 'PUT'}) + responses.append(response) + +@given('a not covered building address') +def step_impl(context): + 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): + 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']) + diff --git a/bloclink/apps/bis/features/submitAnswers.feature b/bloclink/apps/bis/features/submitAnswers.feature new file mode 100644 index 0000000000000000000000000000000000000000..fe469fd002e7810ea2049a411dc79ddfab3fff88 --- /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"