Skip to content
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
9 changes: 9 additions & 0 deletions run_functional_tests
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ export TROVEBOX_TEST_CONFIG=test-hosted
unset TROVEBOX_TEST_SERVER_API
python -m unittest discover --catch tests/functional

# Test account on hosted trovebox.com site over HTTPS
tput setaf 3
echo
echo "Testing latest hosted site over HTTPS..."
tput sgr0
export TROVEBOX_TEST_CONFIG=test-hosted-https
unset TROVEBOX_TEST_SERVER_API
python -m unittest discover --catch tests/functional

9 changes: 5 additions & 4 deletions tests/functional/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ all supported API versions.
To use it, you must set up multiple Trovebox instances and create the following
config files containing your credentials:

test : Latest self-hosted site (from photo/frontend master branch)
test-apiv1 : APIv1 self-hosted site (from photo/frontend commit 660b2ab)
test-3.0.8 : v3.0.8 self-hosted site (from photo/frontend commit e9d81de57b)
test-hosted : Credentials for test account on trovebox.com
test : Latest self-hosted site (from photo/frontend master branch)
test-apiv1 : APIv1 self-hosted site (from photo/frontend commit 660b2ab)
test-3.0.8 : v3.0.8 self-hosted site (from photo/frontend commit e9d81de57b)
test-hosted : Credentials for test account on http://<xxxx>.trovebox.com
test-hosted-https : Same as test-hosted, but with https://
2 changes: 2 additions & 0 deletions tests/functional/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# __init__.py

2 changes: 2 additions & 0 deletions tests/functional/api_versions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# __init__.py

7 changes: 7 additions & 0 deletions tests/functional/api_versions/test_v1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from tests.functional import test_activities, test_actions
from tests.functional import test_albums, test_photos, test_tags

class TestActivitiesV1(test_activities.TestActivities):
api_version = 1

class TestActionsV1(test_actions.TestActions):
api_version = 1

class TestAlbumsV1(test_albums.TestAlbums):
api_version = 1

Expand Down
14 changes: 13 additions & 1 deletion tests/functional/api_versions/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
import unittest2 as unittest
except ImportError:
import unittest
from tests.functional import test_base, test_albums, test_photos, test_tags

from tests.functional import test_base, test_activities, test_actions
from tests.functional import test_albums, test_photos, test_tags

@unittest.skipIf(test_base.get_test_server_api() < 2,
"Don't test future API versions")
class TestActivitiesV2(test_activities.TestActivities):
api_version = 2

@unittest.skipIf(test_base.get_test_server_api() < 2,
"Don't test future API versions")
class TestActionsV2(test_actions.TestActions):
api_version = 2

@unittest.skipIf(test_base.get_test_server_api() < 2,
"Don't test future API versions")
Expand Down
8 changes: 5 additions & 3 deletions tests/functional/test_activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

class TestActivities(test_base.TestBase):
testcase_name = "activity API"


@unittest.skipIf(test_base.get_test_server_api() == 1,
"The activity/list endpoint behaves differenty at v1")
def test_list(self):
"""
"""
Upload three photos, and check that three corresponding activities
are created.
"""
Expand All @@ -36,7 +38,7 @@ 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())
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def setUpClass(cls):
else:
print("\nTesting %s v%d" % (cls.testcase_name, cls.api_version))

cls.client = trovebox.Trovebox(config_file=cls.config_file,
api_version=cls.api_version)
cls.client = trovebox.Trovebox(config_file=cls.config_file)
cls.client.configure(api_version=cls.api_version)

if cls.client.photos.list() != []:
raise ValueError("The test server (%s) contains photos. "
Expand Down
15 changes: 7 additions & 8 deletions tests/functional/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def test_api_version_zero(self):
"""
API v0 has a special hello world message
"""
client = trovebox.Trovebox(config_file=self.config_file,
api_version=0)
client = trovebox.Trovebox(config_file=self.config_file)
client.configure(api_version=0)
result = client.get("hello.json")
self.assertEqual(result['message'],
"Hello, world! This is version zero of the API!")
Expand All @@ -28,8 +28,8 @@ def test_specified_api_version(self):
For all API versions >0, we get a generic hello world message
"""
for api_version in range(1, test_base.get_test_server_api() + 1):
client = trovebox.Trovebox(config_file=self.config_file,
api_version=api_version)
client = trovebox.Trovebox(config_file=self.config_file)
client.configure(api_version=api_version)
result = client.get("hello.json")
self.assertEqual(result['message'], "Hello, world!")
self.assertEqual(result['result']['__route__'],
Expand All @@ -40,8 +40,7 @@ def test_unspecified_api_version(self):
If the API version is unspecified,
we get a generic hello world message.
"""
client = trovebox.Trovebox(config_file=self.config_file,
api_version=None)
client = trovebox.Trovebox(config_file=self.config_file)
result = client.get("hello.json")
self.assertEqual(result['message'], "Hello, world!")
self.assertEqual(result['result']['__route__'], "/hello.json")
Expand All @@ -52,7 +51,7 @@ def test_future_api_version(self):
(ValueError, since the returned 404 HTML page is not valid JSON)
"""
version = trovebox.LATEST_API_VERSION + 1
client = trovebox.Trovebox(config_file=self.config_file,
api_version=version)
client = trovebox.Trovebox(config_file=self.config_file)
client.configure(api_version=version)
with self.assertRaises(trovebox.Trovebox404Error):
client.get("hello.json")