Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @pytest.mark.parametrize(
- 'func_to_test, monkeypatch_target, monkeypatch_attr_name, attr_max_len, monkeypatch_value_from_func', (
- ('get_agcy_cntct_nm', 'self.broker.user', 'get_full_name', 100, True),
- ('get_agcy_cntct_email_addr', 'self.broker.user', 'email', 128, False),
- ('get_insrd_cntct_nm', 'self.client_primary_user', 'get_full_name', 100, True),
- ('get_insrd_cntct_email_addr', 'self.client_primary_user', 'email', 128, False),
- ('get_insrd_nm', 'self.client', 'name', 60, False),
- ('get_insrd_addr_ln_1', 'self.client_profile', 'street', 60, False),
- ('get_insrd_addr_city', 'self.client_profile', 'city', 26, False)
- )
- )
- @pytest.mark.parametrize('len_modifier', (-1, 0, 1, 50))
- def test_validate_max_len(
- self,
- func_to_test,
- monkeypatch_target,
- monkeypatch_attr_name,
- attr_max_len,
- len_modifier,
- monkeypatch_value_from_func
- ):
- value = ''.join(random.choice(string.ascii_lowercase) for _ in range(attr_max_len + len_modifier))
- if monkeypatch_value_from_func:
- MonkeyPatch().setattr(eval(monkeypatch_target), monkeypatch_attr_name, lambda: value)
- else:
- MonkeyPatch().setattr(eval(monkeypatch_target), monkeypatch_attr_name, value)
- returned_value = getattr(self.hanover_csv_generator, func_to_test)()
- assert returned_value == value[:attr_max_len]
- assert len(returned_value) <= attr_max_len
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement