fix unit tests
This commit is contained in:
parent
922ac3b7cf
commit
836e186ab1
2 changed files with 5 additions and 5 deletions
|
|
@ -65,7 +65,7 @@ class TestEntry(object):
|
||||||
|
|
||||||
def test_entry_formatter_fails_missing_field(self, mock_entry):
|
def test_entry_formatter_fails_missing_field(self, mock_entry):
|
||||||
format_string = f"prefix {{bah_humbug}} suffix"
|
format_string = f"prefix {{bah_humbug}} suffix"
|
||||||
available_fields = ", ".join(sorted(mock_entry.to_dict()._keys()))
|
available_fields = ", ".join(sorted(mock_entry.to_dict().keys()))
|
||||||
expected_error_msg = f"Format variable 'bah_humbug' does not exist for Entry. Available fields: {available_fields}"
|
expected_error_msg = f"Format variable 'bah_humbug' does not exist for Entry. Available fields: {available_fields}"
|
||||||
|
|
||||||
with pytest.raises(ValueError, match=expected_error_msg):
|
with pytest.raises(ValueError, match=expected_error_msg):
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,14 @@ class TestEntryFormatter(object):
|
||||||
def test_parse(self):
|
def test_parse(self):
|
||||||
format_string = "Here is my {var_one} and {var_two} 💩"
|
format_string = "Here is my {var_one} and {var_two} 💩"
|
||||||
assert StringFormatterValidator(
|
assert StringFormatterValidator(
|
||||||
name="test_format_variables", format_string=format_string
|
name="test_format_variables", value=format_string
|
||||||
).format_variables == ["var_one", "var_two"]
|
).format_variables == ["var_one", "var_two"]
|
||||||
|
|
||||||
def test_parse_no_variables(self):
|
def test_parse_no_variables(self):
|
||||||
format_string = "No vars 💩"
|
format_string = "No vars 💩"
|
||||||
assert (
|
assert (
|
||||||
StringFormatterValidator(
|
StringFormatterValidator(
|
||||||
name="test_format_variables_empty", format_string=format_string
|
name="test_format_variables_empty", value=format_string
|
||||||
).format_variables
|
).format_variables
|
||||||
== []
|
== []
|
||||||
)
|
)
|
||||||
|
|
@ -49,7 +49,7 @@ class TestEntryFormatter(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(ValidationException, match=expected_error_msg):
|
with pytest.raises(ValidationException, match=expected_error_msg):
|
||||||
_ = StringFormatterValidator(name="fail", format_string=format_string)
|
_ = StringFormatterValidator(name="fail", value=format_string)
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"format_string",
|
"format_string",
|
||||||
|
|
@ -70,4 +70,4 @@ class TestEntryFormatter(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(ValidationException, match=expected_error_msg):
|
with pytest.raises(ValidationException, match=expected_error_msg):
|
||||||
_ = StringFormatterValidator(name="fail", format_string=format_string)
|
_ = StringFormatterValidator(name="fail", value=format_string)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue