From 5c41e75c4709e26382495edab5d2781c4692e7bc Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 27 Jan 2020 16:35:16 -0500 Subject: [PATCH 1/7] Add fixture to setup data injection --- ...questionnaire_data.non_exist_building.json | 147 ++++++++++++++++++ .../data/questionnaire_data_default.json | 147 ++++++++++++++++++ bloclink/apps/pna/features/environment.py | 27 ++++ .../pna/features/steps/submitQuestionnaire.py | 33 ++++ .../pna/features/submitQuestionnaire.feature | 41 +++++ 5 files changed, 395 insertions(+) create mode 100644 bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json create mode 100644 bloclink/apps/pna/features/data/questionnaire_data_default.json create mode 100644 bloclink/apps/pna/features/environment.py create mode 100644 bloclink/apps/pna/features/steps/submitQuestionnaire.py create mode 100644 bloclink/apps/pna/features/submitQuestionnaire.feature 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 0000000..bb74680 --- /dev/null +++ b/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json @@ -0,0 +1,147 @@ +[ + { + "buildingInfo": { + "building_id": "181794", + "firstName": "Jinal", + "lastName": "Soni", + "email": "jinal@blocpower.io", + "phone": "333-333-2233", + "address": "838 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": -1 + }, + "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 0000000..bac05b3 --- /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 0000000..54fe050 --- /dev/null +++ b/bloclink/apps/pna/features/environment.py @@ -0,0 +1,27 @@ +from behave import fixture, use_fixture +from decouple import config +import json + + +@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): + context.basePath = 'http://' + 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 0000000..553be03 --- /dev/null +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -0,0 +1,33 @@ +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): + context.response = requests.get(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire']) + +@when('I click the submit button') +def step_impl(context): + context.response = requests.put(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire'], json=context.inputs, headers={'Content-Type': 'PUT'}) + +@then('result should include code {code}') +def step_impl(context, code): + print(context.response.status_code) + print(context.inputs) + assert code == str(context.response.status_code) + +@then('result should include success as {success}') +def step_impl(context, success): + assert success == str(json.loads(context.response.text)['success']) + +@then('result should include field names {fieldnames}') +def step_impl(context, fieldnames): + response_fieldnames = json.loads(context.response.text).keys() + for fieldname in fieldnames.split(','): + assert fieldname in response_fieldnames + diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature new file mode 100644 index 0000000..030fc4a --- /dev/null +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -0,0 +1,41 @@ +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 + + Examples: Building not exist + | buildingId | code | fieldNames | + | 1699888 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + + Examples: Building has no questionnaire submitted + | buildingId | code | fieldNames | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + | 152699 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + + Examples: Building has questionnaire submitted + | buildingId | code | fieldNames | + | 181794 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + + @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 | + | 1699888 | 500 | + + 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 | -- GitLab From 746d3520adea8172268623d34c9a3855575bc424 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 27 Jan 2020 16:59:14 -0500 Subject: [PATCH 2/7] Update test data --- bloclink/apps/pna/features/steps/submitQuestionnaire.py | 2 -- bloclink/apps/pna/features/submitQuestionnaire.feature | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bloclink/apps/pna/features/steps/submitQuestionnaire.py b/bloclink/apps/pna/features/steps/submitQuestionnaire.py index 553be03..03075d2 100644 --- a/bloclink/apps/pna/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -17,8 +17,6 @@ def step_impl(context): @then('result should include code {code}') def step_impl(context, code): - print(context.response.status_code) - print(context.inputs) assert code == str(context.response.status_code) @then('result should include success as {success}') diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature index 030fc4a..ad9c2c9 100644 --- a/bloclink/apps/pna/features/submitQuestionnaire.feature +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -7,8 +7,8 @@ Feature: A building owner can submit questionnaire And result should include field names Examples: Building not exist - | buildingId | code | fieldNames | - | 1699888 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + | buildingId | code | + | 16998888 | 500 | Examples: Building has no questionnaire submitted | buildingId | code | fieldNames | -- GitLab From 1f1b7822ca0eb5b416d79e9e0841d41c7f11ae24 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 28 Jan 2020 14:58:12 -0500 Subject: [PATCH 3/7] Add test cases & update to use environment variable --- bloclink/apps/pna/features/environment.py | 4 +++- .../apps/pna/features/steps/submitQuestionnaire.py | 4 ++++ .../apps/pna/features/submitQuestionnaire.feature | 11 ++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bloclink/apps/pna/features/environment.py b/bloclink/apps/pna/features/environment.py index 54fe050..993119c 100644 --- a/bloclink/apps/pna/features/environment.py +++ b/bloclink/apps/pna/features/environment.py @@ -1,6 +1,7 @@ from behave import fixture, use_fixture from decouple import config import json +import os @fixture @@ -13,7 +14,8 @@ def before_tag(context, tag): use_fixture(load_questionnaire_inputs, context) def before_all(context): - context.basePath = 'http://' + config('DOMAIN') + '/buildings/' + prefix = 'http://' if config('ENVIRONMENT') == 'local' else 'https://' + context.basePath = prefix + config('DOMAIN') + '/buildings/' context.endpoints = { 'submitQuestionnaire' : '/pna/questionnaire/', 'generateReport' : '/pna/report-generate/', diff --git a/bloclink/apps/pna/features/steps/submitQuestionnaire.py b/bloclink/apps/pna/features/steps/submitQuestionnaire.py index 03075d2..7d91bb2 100644 --- a/bloclink/apps/pna/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -29,3 +29,7 @@ def step_impl(context, fieldnames): for fieldname in fieldnames.split(','): assert fieldname in response_fieldnames +@then('result should include submitted field as {submitted}') +def step_impl(context, submitted): + response = json.loads(context.response.text) + assert submitted == str(response['submitted']) diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature index ad9c2c9..4d7854e 100644 --- a/bloclink/apps/pna/features/submitQuestionnaire.feature +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -5,19 +5,20 @@ Feature: A building owner can submit questionnaire 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 | - | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | - | 152699 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + | buildingId | code | fieldNames | submitted | + | 152699 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | Examples: Building has questionnaire submitted - | buildingId | code | fieldNames | - | 181794 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | + | buildingId | code | fieldNames | submitted | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | + | 181794 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | @load_questionnaire_inputs Scenario Outline: User can submit questionnaire -- GitLab From 645c63bdf72cc1121943b167aa718895ffb48877 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 28 Jan 2020 15:05:58 -0500 Subject: [PATCH 4/7] Update endpoints --- bloclink/apps/pna/features/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bloclink/apps/pna/features/environment.py b/bloclink/apps/pna/features/environment.py index 993119c..55d6b6d 100644 --- a/bloclink/apps/pna/features/environment.py +++ b/bloclink/apps/pna/features/environment.py @@ -18,8 +18,8 @@ def before_all(context): context.basePath = prefix + config('DOMAIN') + '/buildings/' context.endpoints = { 'submitQuestionnaire' : '/pna/questionnaire/', - 'generateReport' : '/pna/report-generate/', - 'downloadReport' : '/pna/report-download/', + 'generateReport' : '/pna/report/generate/', + 'downloadReport' : '/pna/report/download/', } def after_all(context): -- GitLab From d661f4466b59c63261d1f9131e523482bb35c798 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 28 Jan 2020 15:34:07 -0500 Subject: [PATCH 5/7] Add test cases --- bloclink/apps/pna/features/steps/submitQuestionnaire.py | 5 +++++ bloclink/apps/pna/features/submitQuestionnaire.feature | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/bloclink/apps/pna/features/steps/submitQuestionnaire.py b/bloclink/apps/pna/features/steps/submitQuestionnaire.py index 7d91bb2..73a377e 100644 --- a/bloclink/apps/pna/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -33,3 +33,8 @@ def step_impl(context, fieldnames): def step_impl(context, submitted): response = json.loads(context.response.text) assert submitted == str(response['submitted']) + +@then('result should include calculated field as {calculated}') +def step_impl(context, calculated): + response = json.loads(context.response.text) + assert submitted == str(response['calculated']) diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature index 4d7854e..8e7f855 100644 --- a/bloclink/apps/pna/features/submitQuestionnaire.feature +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -20,6 +20,14 @@ Feature: A building owner can submit questionnaire | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | | 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 | True | False | + + Examples: Building report has calculated + | buildingId | code | fieldNames | submitted | calculated | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | True | + @load_questionnaire_inputs Scenario Outline: User can submit questionnaire Given I have the building -- GitLab From ec64b9c907d41d9a7bc92bfeb5f0f0ff167eba85 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Mon, 3 Feb 2020 15:28:10 -0500 Subject: [PATCH 6/7] Fix json loading issue --- ...questionnaire_data.non_exist_building.json | 10 ++--- bloclink/apps/pna/features/environment.py | 2 + .../pna/features/steps/submitQuestionnaire.py | 44 ++++++++++++++----- .../pna/features/submitQuestionnaire.feature | 10 ++--- 4 files changed, 46 insertions(+), 20 deletions(-) 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 index bb74680..331068c 100644 --- a/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json +++ b/bloclink/apps/pna/features/data/questionnaire_data.non_exist_building.json @@ -1,12 +1,12 @@ [ { "buildingInfo": { - "building_id": "181794", - "firstName": "Jinal", - "lastName": "Soni", + "building_id": "", + "firstName": "Jinalllll", + "lastName": "Soniiiii", "email": "jinal@blocpower.io", "phone": "333-333-2233", - "address": "838 PARK PLACE, BROOKLYN", + "address": ["838888 PARK PLACE, BROOKLYN"], "buildingSqFt": 3000, "numberOfFloors": 3, "unitInfo": { @@ -38,7 +38,7 @@ "ownerPayOwnElectricBill": { "question_id": 16, "question": "Do your tenants pay their own electricity bills?", - "answer_id": -1 + "answer_id": 9 }, "accessibleByStairwell": { "question_id": 10, diff --git a/bloclink/apps/pna/features/environment.py b/bloclink/apps/pna/features/environment.py index 55d6b6d..36a3af1 100644 --- a/bloclink/apps/pna/features/environment.py +++ b/bloclink/apps/pna/features/environment.py @@ -2,12 +2,14 @@ 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] + # context.inputs = json.dumps(inputs) def before_tag(context, tag): if tag == "load_questionnaire_inputs": diff --git a/bloclink/apps/pna/features/steps/submitQuestionnaire.py b/bloclink/apps/pna/features/steps/submitQuestionnaire.py index 73a377e..1f46dae 100644 --- a/bloclink/apps/pna/features/steps/submitQuestionnaire.py +++ b/bloclink/apps/pna/features/steps/submitQuestionnaire.py @@ -9,32 +9,56 @@ def step_impl(context, buildingId): @when('I load the questionnaire') def step_impl(context): - context.response = requests.get(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire']) + 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): - context.response = requests.put(url=context.basePath+context.buildingId+context.endpoints['submitQuestionnaire'], json=context.inputs, headers={'Content-Type': 'PUT'}) + # 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 == str(context.response.status_code) + assert code == context.code @then('result should include success as {success}') def step_impl(context, success): - assert success == str(json.loads(context.response.text)['success']) + assert success == context.success @then('result should include field names {fieldnames}') def step_impl(context, fieldnames): - response_fieldnames = json.loads(context.response.text).keys() for fieldname in fieldnames.split(','): - assert fieldname in response_fieldnames + assert fieldname in context.fieldnames @then('result should include submitted field as {submitted}') def step_impl(context, submitted): - response = json.loads(context.response.text) - assert submitted == str(response['submitted']) + assert submitted == context.submitted @then('result should include calculated field as {calculated}') def step_impl(context, calculated): - response = json.loads(context.response.text) - assert submitted == str(response['calculated']) + assert submitted == context.calculated diff --git a/bloclink/apps/pna/features/submitQuestionnaire.feature b/bloclink/apps/pna/features/submitQuestionnaire.feature index 8e7f855..9168430 100644 --- a/bloclink/apps/pna/features/submitQuestionnaire.feature +++ b/bloclink/apps/pna/features/submitQuestionnaire.feature @@ -17,16 +17,16 @@ Feature: A building owner can submit questionnaire Examples: Building has questionnaire submitted | buildingId | code | fieldNames | submitted | - | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | True | + | 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 | True | False | + | 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 | True | True | + | 54321 | 200 | buildingInfo,submittedAnswers,answers,submitted,calculated | False | True | @load_questionnaire_inputs Scenario Outline: User can submit questionnaire @@ -37,8 +37,8 @@ Feature: A building owner can submit questionnaire And result should include field names Examples: Building not exist - | buildingId | code | - | 1699888 | 500 | + | buildingId | code | fieldNames | success | + | 1699888 | 500 | | False | Examples: Building has no questionnaire submitted | buildingId | code | fieldNames | success | -- GitLab From 3c74bf5578c3802ed18a230dac19bcd85f34e760 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 6 Feb 2020 14:12:17 -0500 Subject: [PATCH 7/7] Remove log --- bloclink/apps/pna/features/environment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bloclink/apps/pna/features/environment.py b/bloclink/apps/pna/features/environment.py index 36a3af1..381e252 100644 --- a/bloclink/apps/pna/features/environment.py +++ b/bloclink/apps/pna/features/environment.py @@ -9,7 +9,6 @@ import ast def load_questionnaire_inputs(context): with open('features/data/questionnaire_data.non_exist_building.json', 'r') as outfile: context.inputs = json.load(outfile)[0] - # context.inputs = json.dumps(inputs) def before_tag(context, tag): if tag == "load_questionnaire_inputs": -- GitLab