Skip to content

Fixing Some Nits in Tests #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions integration/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def testref(update_rules):
Returns:
Reference: A reference to the test dinosaur database.
"""
del update_rules
ref = db.reference('_adminsdk/python/dinodb')
ref.set(testdata())
return ref
Expand Down Expand Up @@ -138,10 +139,15 @@ def test_update_children_with_existing_values(self, testref):

def test_update_nested_children(self, testref):
python = testref.parent
ref = python.child('users').push({'name' : 'Edward Cope', 'since' : 1800})
nested_key = '{0}/since'.format(ref.key)
python.child('users').update({nested_key: 1840})
assert ref.get() == {'name' : 'Edward Cope', 'since' : 1840}
edward = python.child('users').push({'name' : 'Edward Cope', 'since' : 1800})
jack = python.child('users').push({'name' : 'Jack Horner', 'since' : 1940})
delta = {
'{0}/since'.format(edward.key) : 1840,
'{0}/since'.format(jack.key) : 1946
}
python.child('users').update(delta)
assert edward.get() == {'name' : 'Edward Cope', 'since' : 1840}
assert jack.get() == {'name' : 'Jack Horner', 'since' : 1946}

def test_delete(self, testref):
python = testref.parent
Expand Down Expand Up @@ -233,6 +239,7 @@ def test_filter_by_value(self, testref):

@pytest.fixture(scope='module')
def override_app(request, update_rules):
del update_rules
cred, project_id = conftest.integration_conf(request)
ops = {
'databaseURL' : 'https://{0}.firebaseio.com'.format(project_id),
Expand All @@ -244,6 +251,7 @@ def override_app(request, update_rules):

@pytest.fixture(scope='module')
def none_override_app(request, update_rules):
del update_rules
cred, project_id = conftest.integration_conf(request)
ops = {
'databaseURL' : 'https://{0}.firebaseio.com'.format(project_id),
Expand Down
2 changes: 2 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ if [[ "$CHECK_ALL" = true ]]
then
lintAllFiles "firebase_admin" ""
lintAllFiles "tests" "$SKIP_FOR_TESTS"
lintAllFiles "integration" "$SKIP_FOR_TESTS"
else
lintChangedFiles "firebase_admin" ""
lintChangedFiles "tests" "$SKIP_FOR_TESTS"
lintChangedFiles "integration" "$SKIP_FOR_TESTS"
fi
6 changes: 4 additions & 2 deletions tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class TestApplicationDefault(object):

@pytest.mark.parametrize('app_default', [testutils.resource_filename('service_account.json')],
indirect=True)
def test_init(self, app_default): # pylint: disable=unused-argument
def test_init(self, app_default):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can suppress these warnings without needing to disable this check for all methods in tests:

For example, here you can

def test_init(self, app_default):
    del app_default

If that's just too annoying, carry on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

del app_default
credential = credentials.ApplicationDefault()
assert credential.project_id == 'mock-project-id'

Expand All @@ -98,7 +99,8 @@ def test_init(self, app_default): # pylint: disable=unused-argument

@pytest.mark.parametrize('app_default', [testutils.resource_filename('non_existing.json')],
indirect=True)
def test_nonexisting_path(self, app_default): # pylint: disable=unused-argument
def test_nonexisting_path(self, app_default):
del app_default
with pytest.raises(IOError):
credentials.ApplicationDefault()

Expand Down
3 changes: 2 additions & 1 deletion tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def __init__(self, data, status, recorder):
self._status = status
self._recorder = recorder

def send(self, request, **kwargs): # pylint: disable=unused-argument
def send(self, request, **kwargs):
del kwargs
self._recorder.append(request)
resp = models.Response()
resp.url = request.url
Expand Down