Skip to content

Commit

Permalink
Merge pull request #11 from kevinjqiu/issue-#10
Browse files Browse the repository at this point in the history
Add doc string and invalid argument check. See #10
  • Loading branch information
kevinjqiu committed Jul 5, 2014
2 parents f9fbd46 + d6c8959 commit 237dfe3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: python
python:
- "2.6"
- "2.7"
install:
- pip install coveralls
Expand Down
16 changes: 16 additions & 0 deletions btsync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@ def __str__(self):


class Client(object):
"""
Client
~~~~~~
The client that talks to the hosted btsync instance.
"""
def __init__(self, **kwargs):
"""Constructor
:params host: the host of the btsync instance to talk to
:param port: the port of the btsync instance to talk to
:param username: the admin username for the btsync instance
:param password: the admin password for the btsync instance
"""
self._host = kwargs.pop('host', '127.0.0.1')
self._port = kwargs.pop('port', '8888')
self._username = kwargs.pop('username', 'admin')
self._password = kwargs.pop('password', 'password')

assert len(kwargs.keys()) == 0, \
"Unrecognized params: %r" % kwargs.keys()
self._session = self._authenticate()

def _make_request(self, **kwargs):
Expand Down
12 changes: 11 additions & 1 deletion test/unit/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from mock import call, patch, Mock
from nose.tools import eq_, raises
from nose.tools import eq_, raises, assert_raises

import btsync
from responses import ResponseFixtures
Expand All @@ -8,6 +8,16 @@
fixtures = ResponseFixtures()


def test_unrecognized_params_used_to_construct_client():
with assert_raises(AssertionError) as e:
btsync.Client(host='192.168.1.1',
port='5555',
user='admin',
pwd='admin')
eq_("Unrecognized params: ['pwd', 'user']",
str(e.exception))


class TestClient(object):
patchers = []

Expand Down

0 comments on commit 237dfe3

Please sign in to comment.