forked from tomgross/pcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validator for all required parameters
- Loading branch information
Showing
4 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
import pytest | ||
from pcloud.validate import RequiredParameterCheck | ||
from pcloud.validate import MODE_AND | ||
|
||
|
||
@RequiredParameterCheck(('path', 'folderid')) | ||
def foo(self, path=None, folderid=None, bar=None): | ||
return (path, folderid, bar) | ||
def foo(path=None, folderid=None, bar=None): | ||
return path, folderid, bar | ||
|
||
|
||
@RequiredParameterCheck(('path', 'folderid'), mode=MODE_AND) | ||
def foo_all(path=None, folderid=None, bar=None): | ||
return path, folderid, bar | ||
|
||
|
||
class TestPathIdentifier(object): | ||
|
||
def test_validiate_path(self): | ||
assert foo(None, path='/', bar='x') == ('/', None, 'x') | ||
assert foo(path='/', bar='x') == ('/', None, 'x') | ||
|
||
def test_validiate_folderid(self): | ||
assert foo(None, folderid='0') == (None, '0', None) | ||
assert foo(folderid='0') == (None, '0', None) | ||
|
||
def test_validiate_nothing(self): | ||
with pytest.raises(ValueError): | ||
foo(None, bar='something') | ||
foo(bar='something') | ||
|
||
def test_validiate_all_path(self): | ||
with pytest.raises(ValueError): | ||
foo_all(path='/', bar='x') | ||
|
||
def test_validiate_all_folderid(self): | ||
with pytest.raises(ValueError): | ||
foo_all(folderid='0') == (None, '0', None) | ||
|
||
def test_validiate_all(self): | ||
foo_all(folderid='0', path='/') == ('/', '0', None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pytest >= 2.8 | |
tox | ||
wheel | ||
flake8 | ||
fs |