Add regexp field to ip dns static (#142)

* Add regexp field to "ip dns static"

* Change test_invalid_required_missing to use "ip dhcp-server"

"ip dns static" requires name or regexp so it cannot be used in this test.

* Add required_one_of attribute to APIData

Used by "ip dns static" which requires either "name" or "regexp.

* Add mutually_exclusive attribute to APIData

Used by "ip dns static" where only one of "name" or "regexp" can be used.

* Add changelog fragment
This commit is contained in:
Andrei Costescu 2022-12-29 08:51:40 +01:00 committed by GitHub
parent 62da7dd4e3
commit 586edbc211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 4 deletions

View file

@ -54,6 +54,22 @@ def test_api_data_errors():
APIData(stratify_keys=['foo'], fields={})
assert exc.value.args[0] == 'Stratify key foo must be in fields!'
with pytest.raises(ValueError) as exc:
APIData(required_one_of=['foo'], fields={})
assert exc.value.args[0] == 'Require one of element at index #1 must be a list!'
with pytest.raises(ValueError) as exc:
APIData(required_one_of=[['foo']], fields={})
assert exc.value.args[0] == 'Require one of key foo must be in fields!'
with pytest.raises(ValueError) as exc:
APIData(mutually_exclusive=['foo'], fields={})
assert exc.value.args[0] == 'Mutually exclusive element at index #1 must be a list!'
with pytest.raises(ValueError) as exc:
APIData(mutually_exclusive=[['foo']], fields={})
assert exc.value.args[0] == 'Mutually exclusive key foo must be in fields!'
def test_key_info_errors():
values = [