def validate(self, method, *args, **kwargs): """Validate authentication and values passed to the specified method. Raises a PyCronofyValidationError on error. :param string method: Method name to check. :param *args: Arguments for "Method". :param **kwargs: Keyword arguments for "Method". """ validate(method, self.auth, *args, **kwargs)
def test_validate(): """Test if validate properly validates methods.""" auth = Auth(access_token='access') validate('create_notification_channel', auth, 'http://example.com', calendar_ids=('id',), ) with pytest.raises(PyCronofyValidationError) as exception_info: validate('create_notification_channel', auth) assert 'callback_url' in exception_info.value.fields with pytest.raises(PyCronofyValidationError) as exception_info: validate('create_notification_channel', Auth(), 'http://example.com', calendar_ids=('id',) ) assert 'access_token' in exception_info.value.fields with pytest.raises(PyCronofyValidationError) as exception_info: validate('ask_for_cats', Auth(), 'http://example.com') assert exception_info.value.message == 'Method "ask_for_cats" not found.'