mirror of
https://github.com/khornberg/octokit.py
synced 2026-05-12 03:10:49 +03:00
Bug Fix: Properly verify and check required nested parameters
This commit is contained in:
@@ -66,6 +66,44 @@ class TestClientMethods(object):
|
||||
Octokit().oauth_authorizations.create_authorization(**data)
|
||||
assert 'None is not a valid parameter for gist_id' == str(e.value)
|
||||
|
||||
def test_must_include_required_dictionary_sub_parameters_when_used(self, mocker):
|
||||
mocker.patch('requests.get')
|
||||
data = {
|
||||
'owner': 'owner',
|
||||
'repo': 'repo',
|
||||
'name': 'name',
|
||||
'head_sha': 'master',
|
||||
'output': {}
|
||||
}
|
||||
with pytest.raises(errors.OctokitParameterError) as e:
|
||||
Octokit().checks.create(**data)
|
||||
assert 'output.title is a required parameter' == str(e.value)
|
||||
data.update({'output': {'title': 'blah'}})
|
||||
with pytest.raises(errors.OctokitParameterError) as e:
|
||||
Octokit().checks.create(**data)
|
||||
assert 'output.summary is a required parameter' == str(e.value)
|
||||
data.update({'output': {'title': 'blah', 'summary': 'that'}})
|
||||
Octokit().checks.create(**data)
|
||||
|
||||
def test_must_include_required_list_sub_parameters_when_used(self, mocker):
|
||||
mocker.patch('requests.get')
|
||||
data = {
|
||||
'owner': 'owner',
|
||||
'repo': 'repo',
|
||||
'name': 'name',
|
||||
'head_sha': 'master',
|
||||
'actions': []
|
||||
}
|
||||
with pytest.raises(errors.OctokitParameterError) as e:
|
||||
Octokit().checks.create(**data)
|
||||
assert 'actions.label is a required parameter' == str(e.value)
|
||||
data.update({'actions': {'label': 'blah'}})
|
||||
with pytest.raises(errors.OctokitParameterError) as e:
|
||||
Octokit().checks.create(**data)
|
||||
assert 'actions.description is a required parameter' == str(e.value)
|
||||
data.update({'actions': {'label': 'blah', 'description': 'x', 'identifier': 'a'}})
|
||||
Octokit().checks.create(**data)
|
||||
|
||||
def test_use_default_parameter_values(self, mocker):
|
||||
mocker.patch('requests.get')
|
||||
headers = {'Content-Type': 'application/json', 'accept': 'application/vnd.github.v3+json'}
|
||||
|
||||
Reference in New Issue
Block a user