diff --git a/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json b/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json new file mode 100644 index 0000000000000000000000000000000000000000..331068c3b941f3a01de1ed78a13e805be8ee3fb0 --- /dev/null +++ b/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json @@ -0,0 +1,147 @@ +[ + { + "buildingInfo": { + "building_id": "", + "firstName": "Jinalllll", + "lastName": "Soniiiii", + "email": "jinal@blocpower.io", + "phone": "333-333-2233", + "address": ["838888 PARK PLACE, BROOKLYN"], + "buildingSqFt": 3000, + "numberOfFloors": 3, + "unitInfo": { + "studio": 1, + "oneBedroom": 1, + "twoBedroom": 1, + "threeBedroom": 1, + "fourBedroom": 1, + "other": "other", + "numOfOther": 0 + } + }, + "remoteSurvey": { + "heatingSystem": { + "question_id": 1, + "question": "Heating System", + "answer_id": 3 + }, + "heatingFuelSource": { + "question_id": 2, + "question": "Heating Fuel Source", + "answer_id": 6 + }, + "DHWSameBoiler": { + "question_id": 3, + "question": "Is Domestic Hot Water (DHW) and heat prepared by the same boiler?", + "answer_id": 10 + }, + "ownerPayOwnElectricBill": { + "question_id": 16, + "question": "Do your tenants pay their own electricity bills?", + "answer_id": 9 + }, + "accessibleByStairwell": { + "question_id": 10, + "question": "Is the roof flat and easily accessible by a stairwell?", + "answer_id": 9 + }, + "meteredForElectricity": { + "question_id": 15, + "question": "Is the building direct metered for electricity (tenant pay ConEd bills)?", + "answer_id": 10 + }, + "ageOfHeatGenerateSystem": { + "question_id": 4, + "question": "Age of the heat generating system?", + "answer_id": 13 + }, + "tenantComplaintsWindows": { + "question_id": 14, + "question": "Any tenant complaints about drafty windows?", + "answer_id": 26 + }, + "stairwellsHeated": { + "question_id": 7, + "question": "Are the following building areas heated? (stairwells)", + "answer_id": 9 + }, + "hallwaysHeated": { + "question_id": 6, + "question": "Are the following building areas heated? (hallways)", + "answer_id": 10 + }, + "basementHeated": { + "question_id": 8, + "question": "Are the following building areas heated? (basement)", + "answer_id": 9 + }, + "tenantComplaintsComfort": { + "question_id": 13, + "question": "Any tenant complaints about comfort issues? (Temperature)", + "answer_id": 23 + }, + "planToReplaceHS": { + "question_id": 5, + "question": "When do you plan to replace the heating system?", + "answer_id": 16 + }, + "backFacadeAttached": { + "question_id": 11, + "question": "Is the back facade of your building attached to an adjacent building or structure?", + "answer_id": 10 + }, + "exteriorWallsAttached": { + "question_id": 12, + "question": "Are the exterior walls of your building attached to an adjacent building or structure?", + "answer_id": 10 + }, + "floorsHeated": { + "question_id": 9, + "question": "Are the following building areas heated? (floors)", + "answer_id": 9 + }, + "numberOfHeatingViolations": { + "question_id": 23, + "question": "Number of heating violations in 5 years?", + "answer_id": 45 + } + }, + "financialInitials": { + "bankruptcyPast": { + "question_id": 17, + "question": "Any bankruptcy in the past three years?", + "answer_id": 10 + }, + "currentOnEnergyBills": { + "question_id": 18, + "question": "Current on energy bills?", + "answer_id": 30 + }, + "currentMortgageBalance": { + "question_id": 19, + "question": "What is the current outstanding balance of the mortgage?", + "answer_id": 34 + }, + "profitable": { + "question_id": 20, + "question": "Is your building currently profitable?", + "answer_id": 40 + }, + "budgetForDownPayment": { + "question_id": 21, + "question": "What is your current budget for a down payment?", + "answer_id": 41 + }, + "legalOwnership": { + "question_id": 22, + "question": "Legal Ownership", + "answer_id": 53 + }, + "numberOfDobViolations": { + "question_id": 24, + "question": "Number of DOB violations?", + "answer_id": 48 + } + } + } +] diff --git a/bloclink/apps/pna/features/data/questionnaire_data_default.json b/bloclink/apps/pna/features/data/questionnaire_data_default.json new file mode 100644 index 0000000000000000000000000000000000000000..bac05b3a55e8c1f4c19a549707db41a73d4d2fb0 --- /dev/null +++ b/bloclink/apps/pna/features/data/questionnaire_data_default.json @@ -0,0 +1,147 @@ +[ + { + "buildingInfo": { + "building_id": "", + "firstName": "", + "lastName": "", + "email": "", + "phone": "", + "address": "", + "buildingSqFt": "", + "numberOfFloors": "", + "unitInfo": { + "studio": "", + "oneBedroom": "", + "twoBedroom": "", + "threeBedroom": "", + "fourBedroom": "", + "other": "", + "numOfOther": "" + } + }, + "remoteSurvey": { + "heatingSystem": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "heatingFuelSource": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "DHWSameBoiler": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "ownerPayOwnElectricBill": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "accessibleByStairwell": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "meteredForElectricity": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "ageOfHeatGenerateSystem": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "tenantComplaintsWindows": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "stairwellsHeated": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "hallwaysHeated": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "basementHeated": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "tenantComplaintsComfort": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "planToReplaceHS": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "backFacadeAttached": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "exteriorWallsAttached": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "floorsHeated": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "numberOfHeatingViolations": { + "question_id": "", + "question": "", + "answer_id": "" + } + }, + "financialInitials": { + "bankruptcyPast": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "currentOnEnergyBills": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "currentMortgageBalance": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "profitable": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "budgetForDownPayment": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "legalOwnership": { + "question_id": "", + "question": "", + "answer_id": "" + }, + "numberOfDobViolations": { + "question_id": "", + "question": "", + "answer_id": "" + } + } + } +] diff --git a/bloclink/apps/pna/features/environment.py b/bloclink/apps/pna/features/environment.py new file mode 100644 index 0000000000000000000000000000000000000000..381e2524fb0616adcfb0f94c5c3c6c300dc15077 --- /dev/null +++ b/bloclink/apps/pna/features/environment.py @@ -0,0 +1,30 @@ +from behave import fixture, use_fixture +from decouple import config +import json +import os +import ast + + +@fixture +def load_questionnaire_inputs(context): + with open('features/data/questionnaire_data.non_exist_building.json', 'r') as outfile: + context.inputs = json.load(outfile)[0] + +def before_tag(context, tag): + if tag == "load_questionnaire_inputs": + use_fixture(load_questionnaire_inputs, context) + +def before_all(context): + prefix = 'http://' if config('ENVIRONMENT') == 'local' else 'https://' + context.basePath = prefix + config('DOMAIN') + '/buildings/' + context.endpoints = { + 'submitQuestionnaire' : '/pna/questionnaire/', + 'generateReport' : '/pna/report/generate/', + 'downloadReport' : '/pna/report/download/', + } + +def after_all(context): + pass + +def before_feature(context, feature): + pass diff --git a/bloclink/apps/pna/features/steps/submitQuestionnaire.py b/bloclink/apps/pna/features/steps/submitQuestionnaire.py new file mode 100644 index 0000000000000000000000000000000000000000..1f46daec532e89667a91859d929555eb7edafb14 --- /dev/null +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -0,0 +1,64 @@ +from behave import * +import requests +import json + + +@given('I have the building {buildingId}') +def step_impl(context, buildingId): + context.buildingId = buildingId + +@when('I load the questionnaire') +def step_impl(context): + response = requests.get(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire']) + context.code = str(response.status_code) + try: + response_obj = json.loads(response.text) + context.submitted = str(response_obj['submitted']) + context.calculated = str(response_obj['calculated']) + context.fieldnames = response_obj.keys() + except: + context.submitted = "False" + context.calculated = "False" + context.fieldnames = [] + + try: + context.success = str(response_obj['success']) + except: + context.success = 'True' + +@when('I click the submit button') +def step_impl(context): + # Fill out building ID + buildingInfo = context.inputs['buildingInfo'] + buildingInfo['building_id'] = context.buildingId + context.inputs['buildingInfo'] = buildingInfo + response = requests.put(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire'], json=context.inputs) + context.code = str(response.status_code) + try: + response_obj = json.loads(response.text) + context.success = str(response_obj['success']) + context.fieldnames = response_obj.keys() + except: + context.success = "False" + context.fieldnames = [] + +@then('result should include code {code}') +def step_impl(context, code): + assert code == context.code + +@then('result should include success as {success}') +def step_impl(context, success): + assert success == context.success + +@then('result should include field names {fieldnames}') +def step_impl(context, fieldnames): + for fieldname in fieldnames.split(','): + assert fieldname in context.fieldnames + +@then('result should include submitted field as {submitted}') +def step_impl(context, submitted): + assert submitted == context.submitted + +@then('result should include calculated field as {calculated}') +def step_impl(context, calculated): + assert submitted == context.calculated diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature new file mode 100644 index 0000000000000000000000000000000000000000..9168430ad97b1f820a9bb7a36f48bbf6627302f5 --- /dev/null +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -0,0 +1,50 @@ +Feature: A building owner can submit questionnaire + + Scenario Outline: User can load questionnaire + Given I have the building + When I load the questionnaire + Then result should include code + And result should include field names + And result should include submitted field as + + Examples: Building not exist + | buildingId | code | + | 16998888 | 500 | + + Examples: Building has no questionnaire submitted + | buildingId | code | fieldNames | submitted | + | 152699 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | + + Examples: Building has questionnaire submitted + | buildingId | code | fieldNames | submitted | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | + | 181794 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | + + Examples: Building report has not calculated + | buildingId | code | fieldNames | submitted | calculated | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | False | + + Examples: Building report has calculated + | buildingId | code | fieldNames | submitted | calculated | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | True | + + @load_questionnaire_inputs + Scenario Outline: User can submit questionnaire + Given I have the building + When I click the submit button + Then result should include code + And result should include success as + And result should include field names + + Examples: Building not exist + | buildingId | code | fieldNames | success | + | 1699888 | 500 | | False | + + Examples: Building has no questionnaire submitted + | buildingId | code | fieldNames | success | + | 54321 | 200 | message,answers | True | + | 152699 | 200 | message,answers | True | + + Examples: Building has questionnaire submitted + | buildingId | code | fieldNames | success | + | 181794 | 200 | message,answers | True |