Skip to content

Commit 9cf28b0

Browse files
committed
Increase resilience of web API tests
1 parent f769804 commit 9cf28b0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/web_api/test_variables.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ def test_variable_formula_github_link():
9494

9595

9696
def test_variable_formula_content():
97-
formula_code = "def formula(person, period, parameters):\n \"\"\"\n Income tax.\n\n The formula to compute the income tax for a given person at a given period\n \"\"\"\n return person(\"salary\", period) * parameters(period).taxes.income_tax_rate\n"
98-
assert variable['formulas']['0001-01-01']['content'] == formula_code
97+
content = variable['formulas']['0001-01-01']['content']
98+
assert "def formula(person, period, parameters):" in content
99+
assert "return person(\"salary\", period) * parameters(period).taxes.income_tax_rate" in content
99100

100101

101102
def test_null_values_are_dropped():
@@ -157,4 +158,6 @@ def test_variable_documentation():
157158
variable = json.loads(response.data.decode('utf-8'))
158159
assert variable['documentation'] == "This allowance was introduced on the 1st of Jan 1980.\nIt disappeared in Dec 2016."
159160

160-
assert variable['formulas']['1980-01-01']['documentation'] == "\nHousing allowance.\n\nThis allowance was introduced on the 1st of Jan 1980.\nCalculating it before this date will always return the variable default value, 0.\n\nTo compute this allowance, the 'rent' value must be provided for the same month,\nbut 'housing_occupancy_status' is not necessary.\n"
161+
formula_documentation = variable['formulas']['1980-01-01']['documentation']
162+
assert "Housing allowance." in formula_documentation
163+
assert "Calculating it before this date will always return the variable default value, 0." in formula_documentation

0 commit comments

Comments
 (0)