-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
2,665 additions
and
1,163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# .coveragerc to control coverage.py | ||
[run] | ||
# Capture branch coverage | ||
branch = True |
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 |
---|---|---|
|
@@ -6,3 +6,5 @@ dist | |
tests/tokens.py | ||
tests.log | ||
.tox | ||
.coverage | ||
htmlcov |
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,15 +1,23 @@ | ||
language: python | ||
|
||
install: | ||
# Install test dependencies | ||
- pip install tox --use-mirrors | ||
- .travis/install_pylint | ||
- pip install coveralls --use-mirrors | ||
|
||
script: tox | ||
|
||
after_success: | ||
# Send coverage results to coveralls.io | ||
- coveralls | ||
|
||
after_script: | ||
# Install dependencies for Pylint | ||
- pip install requests requests-oauthlib | ||
- pip install pylint-patcher --use-mirrors | ||
- pip install requests --use-mirrors | ||
- pip install requests-oauthlib --use-mirrors | ||
|
||
# Run Pylint | ||
# Uses pylint-patcher to allow exceptions to be stored in a patchfile | ||
# (for information only, any errors don't affect the Travis result) | ||
- pylint --use-ignore-patch=y trovebox | ||
- pylint-patcher trovebox |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[MESSAGES CONTROL] | ||
# Enable the message, report, category or checker with the given id(s). You can | ||
# either give multiple identifier separated by comma (,) or put this option | ||
# multiple time. See also the "--disable" option for examples. | ||
#enable= | ||
|
||
# Disable the message, report, category or checker with the given id(s). You | ||
# can either give multiple identifiers separated by comma (,) or put this | ||
# option multiple times (only on the command line, not in the configuration | ||
# file where it should appear only once).You can also use "--disable=all" to | ||
# disable everything first and then reenable specific checks. For example, if | ||
# you want to run only the similarities checker, you can use "--disable=all | ||
# --enable=similarities". If you want to run only the classes checker, but have | ||
# no Warning level messages displayed, use"--disable=all --enable=classes | ||
# --disable=W" | ||
disable=locally-disabled |
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# __init__.py | ||
|
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# __init__.py | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
try: | ||
import unittest2 as unittest # Python2.6 | ||
except ImportError: | ||
import unittest | ||
|
||
import trovebox | ||
from tests.functional import test_base | ||
|
||
class TestActions(test_base.TestBase): | ||
testcase_name = "action API" | ||
|
||
def test_create_view_delete(self): | ||
""" Create an action on a photo, view it, then delete it """ | ||
# Create and check that the action exists | ||
action = self.client.action.create(target=self.photos[0], type="comment", name="test") | ||
action_id = action.id | ||
self.assertEqual(self.client.action.view(action_id).name, "test") | ||
|
||
# Delete and check that the action is gone | ||
action.delete() | ||
with self.assertRaises(trovebox.TroveboxError): | ||
self.client.action.view(action_id) | ||
|
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
try: | ||
import unittest2 as unittest # Python2.6 | ||
except ImportError: | ||
import unittest | ||
|
||
from tests.functional import test_base | ||
|
||
@unittest.skipIf(test_base.get_test_server_api() == 1, | ||
("Activities never get deleted in v1, which makes " | ||
"these tests too hard to write")) | ||
class TestActivities(test_base.TestBase): | ||
testcase_name = "activity API" | ||
|
||
def test_list(self): | ||
""" | ||
Upload three photos, and check that three corresponding activities | ||
are created. | ||
""" | ||
self._delete_all() | ||
self._create_test_photos(tag=False) | ||
photos = self.client.photos.list() | ||
|
||
# Check that each activity is for a valid test photo | ||
activities = self.client.activities.list() | ||
self.assertEqual(len(activities), len(photos)) | ||
for activity in activities: | ||
self.assertIn(activity.data.id, [photo.id for photo in photos]) | ||
|
||
# Put the environment back the way we found it | ||
for photo in photos: | ||
photo.update(tags=self.TEST_TAG) | ||
|
||
def test_list_option(self): | ||
""" | ||
Check that the activity list options parameter works correctly | ||
""" | ||
self._delete_all() | ||
self._create_test_photos(tag=False) | ||
photos = self.client.photos.list() | ||
|
||
# Dummy photo update activity | ||
photos[0].update(tags=photos[0].tags) | ||
|
||
# Check that the activities can be filtered | ||
upload_activities = self.client.activities.list(options={"type": "photo-upload"}) | ||
update_activities = self.client.activities.list(options={"type": "photo-update"}) | ||
self.assertEqual(len(upload_activities), len(photos)) | ||
self.assertEqual(len(update_activities), 1) | ||
|
||
# Put the environment back the way we found it | ||
for photo in photos: | ||
photo.update(tags=self.TEST_TAG) | ||
|
||
# The purge endpoint currently reports a 500: Internal Server Error | ||
# PHP Fatal error: | ||
# Call to undefined method DatabaseMySql::postActivitiesPurge() | ||
# in /var/www/openphoto-master/src/libraries/models/Activity.php | ||
# on line 66 | ||
# Tracked in frontend/#1368 | ||
@unittest.expectedFailure | ||
def test_purge(self): | ||
""" Test that the purge endpoint deletes all activities """ | ||
activities = self.client.activities.list() | ||
self.assertNotEqual(activities, []) | ||
self.client.activities.purge() | ||
activities = self.client.activities.list() | ||
self.assertEqual(activities, []) | ||
|
||
def test_view(self): | ||
""" Test that the view endpoint is working correctly """ | ||
activity = self.client.activities.list()[0] | ||
fields = activity.get_fields().copy() | ||
|
||
# Check that the view method returns the same data as the list | ||
activity.view() | ||
self.assertEqual(fields, activity.get_fields()) | ||
|
||
# Check using the Trovebox class | ||
activity = self.client.activity.view(activity) | ||
self.assertEqual(fields, activity.get_fields()) | ||
|
||
# Check passing the activity ID to the Trovebox class | ||
activity = self.client.activity.view(activity.id) | ||
self.assertEqual(fields, activity.get_fields()) |
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
Oops, something went wrong.