diff --git a/run_tests b/run_functional_tests similarity index 65% rename from run_tests rename to run_functional_tests index b800038..5208de8 100755 --- a/run_tests +++ b/run_functional_tests @@ -1,10 +1,9 @@ #!/bin/bash # -# Simple script to run all tests with multiple test servers -# across all supported Python versions +# Simple script to run all functional tests with multiple test servers # -# Default test server running latest self-hosted site +# Test server running latest self-hosted site tput setaf 3 echo @@ -12,7 +11,7 @@ echo "Testing latest self-hosted site..." tput sgr0 export OPENPHOTO_TEST_CONFIG=test unset OPENPHOTO_TEST_SERVER_API -tox $@ +python -m unittest discover --catch tests/functional # Test server running APIv1 OpenPhoto instance tput setaf 3 @@ -21,7 +20,7 @@ echo "Testing APIv1 self-hosted site..." tput sgr0 export OPENPHOTO_TEST_CONFIG=test-apiv1 export OPENPHOTO_TEST_SERVER_API=1 -tox $@ +python -m unittest discover --catch tests/functional # Test account on hosted trovebox.com site tput setaf 3 @@ -30,5 +29,5 @@ echo "Testing latest hosted site..." tput sgr0 export OPENPHOTO_TEST_CONFIG=test-hosted unset OPENPHOTO_TEST_SERVER_API -tox $@ +python -m unittest discover --catch tests/functional diff --git a/tests/test_photo1.jpg b/tests/data/test_photo1.jpg similarity index 100% rename from tests/test_photo1.jpg rename to tests/data/test_photo1.jpg diff --git a/tests/test_photo2.jpg b/tests/data/test_photo2.jpg similarity index 100% rename from tests/test_photo2.jpg rename to tests/data/test_photo2.jpg diff --git a/tests/test_photo3.jpg b/tests/data/test_photo3.jpg similarity index 100% rename from tests/test_photo3.jpg rename to tests/data/test_photo3.jpg diff --git a/tests/api_versions/__init__.py b/tests/functional/__init__.py similarity index 100% rename from tests/api_versions/__init__.py rename to tests/functional/__init__.py diff --git a/tests/functional/api_versions/__init__.py b/tests/functional/api_versions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/api_versions/test_v1.py b/tests/functional/api_versions/test_v1.py similarity index 74% rename from tests/api_versions/test_v1.py rename to tests/functional/api_versions/test_v1.py index 92baabb..aa3c652 100644 --- a/tests/api_versions/test_v1.py +++ b/tests/functional/api_versions/test_v1.py @@ -1,4 +1,4 @@ -from tests import test_albums, test_photos, test_tags +from tests.functional import test_albums, test_photos, test_tags class TestAlbumsV1(test_albums.TestAlbums): api_version = 1 diff --git a/tests/api_versions/test_v2.py b/tests/functional/api_versions/test_v2.py similarity index 88% rename from tests/api_versions/test_v2.py rename to tests/functional/api_versions/test_v2.py index 545e647..a2c425c 100644 --- a/tests/api_versions/test_v2.py +++ b/tests/functional/api_versions/test_v2.py @@ -2,7 +2,7 @@ try: import unittest2 as unittest except ImportError: import unittest -from tests import test_base, test_albums, test_photos, test_tags +from tests.functional import test_base, test_albums, test_photos, test_tags @unittest.skipIf(test_base.get_test_server_api() < 2, "Don't test future API versions") diff --git a/tests/test_albums.py b/tests/functional/test_albums.py similarity index 97% rename from tests/test_albums.py rename to tests/functional/test_albums.py index c48420e..95b28ab 100644 --- a/tests/test_albums.py +++ b/tests/functional/test_albums.py @@ -1,6 +1,6 @@ -import tests.test_base +from tests.functional import test_base -class TestAlbums(tests.test_base.TestBase): +class TestAlbums(test_base.TestBase): testcase_name = "album API" def test_create_delete(self): diff --git a/tests/test_base.py b/tests/functional/test_base.py similarity index 96% rename from tests/test_base.py rename to tests/functional/test_base.py index eb05caf..2c3926e 100644 --- a/tests/test_base.py +++ b/tests/functional/test_base.py @@ -128,13 +128,13 @@ class TestBase(unittest.TestCase): """ Upload three test photos """ album = cls.client.album.create(cls.TEST_ALBUM) photos = [ - cls.client.photo.upload("tests/test_photo1.jpg", + cls.client.photo.upload("tests/data/test_photo1.jpg", title=cls.TEST_TITLE, albums=album.id), - cls.client.photo.upload("tests/test_photo2.jpg", + cls.client.photo.upload("tests/data/test_photo2.jpg", title=cls.TEST_TITLE, albums=album.id), - cls.client.photo.upload("tests/test_photo3.jpg", + cls.client.photo.upload("tests/data/test_photo3.jpg", title=cls.TEST_TITLE, albums=album.id), ] diff --git a/tests/test_framework.py b/tests/functional/test_framework.py similarity index 93% rename from tests/test_framework.py rename to tests/functional/test_framework.py index 6d34f73..788ac13 100644 --- a/tests/test_framework.py +++ b/tests/functional/test_framework.py @@ -1,9 +1,9 @@ import logging import openphoto -import tests.test_base +from tests.functional import test_base -class TestFramework(tests.test_base.TestBase): +class TestFramework(test_base.TestBase): testcase_name = "framework" def setUp(self): @@ -27,7 +27,7 @@ class TestFramework(tests.test_base.TestBase): """ For all API versions >0, we get a generic hello world message """ - for api_version in range(1, tests.test_base.get_test_server_api() + 1): + for api_version in range(1, test_base.get_test_server_api() + 1): client = openphoto.OpenPhoto(config_file=self.config_file, api_version=api_version) result = client.get("hello.json") diff --git a/tests/test_photos.py b/tests/functional/test_photos.py similarity index 94% rename from tests/test_photos.py rename to tests/functional/test_photos.py index d0029a4..c6c9b57 100644 --- a/tests/test_photos.py +++ b/tests/functional/test_photos.py @@ -1,9 +1,9 @@ from __future__ import unicode_literals import openphoto -import tests.test_base +from tests.functional import test_base -class TestPhotos(tests.test_base.TestBase): +class TestPhotos(test_base.TestBase): testcase_name = "photo API" def test_delete_upload(self): @@ -19,11 +19,11 @@ class TestPhotos(tests.test_base.TestBase): self.assertEqual(self.client.photos.list(), []) # Re-upload the photos, one of them using Bas64 encoding - ret_val = self.client.photo.upload("tests/test_photo1.jpg", + ret_val = self.client.photo.upload("tests/data/test_photo1.jpg", title=self.TEST_TITLE) - self.client.photo.upload("tests/test_photo2.jpg", + self.client.photo.upload("tests/data/test_photo2.jpg", title=self.TEST_TITLE) - self.client.photo.upload_encoded("tests/test_photo3.jpg", + self.client.photo.upload_encoded("tests/data/test_photo3.jpg", title=self.TEST_TITLE) # Check there are now three photos with the correct titles @@ -61,7 +61,7 @@ class TestPhotos(tests.test_base.TestBase): """ Ensure that duplicate photos are rejected """ # Attempt to upload a duplicate with self.assertRaises(openphoto.OpenPhotoDuplicateError): - self.client.photo.upload("tests/test_photo1.jpg", + self.client.photo.upload("tests/data/test_photo1.jpg", title=self.TEST_TITLE) # Check there are still three photos diff --git a/tests/test_tags.py b/tests/functional/test_tags.py similarity index 96% rename from tests/test_tags.py rename to tests/functional/test_tags.py index 40a577e..14ed6c0 100644 --- a/tests/test_tags.py +++ b/tests/functional/test_tags.py @@ -3,11 +3,11 @@ try: except ImportError: import unittest -import tests.test_base +from tests.functional import test_base -@unittest.skipIf(tests.test_base.get_test_server_api() == 1, +@unittest.skipIf(test_base.get_test_server_api() == 1, "The tag API didn't work at v1 - see frontend issue #927") -class TestTags(tests.test_base.TestBase): +class TestTags(test_base.TestBase): testcase_name = "tag API" def test_create_delete(self, tag_id="create_tag"): diff --git a/tests/test_config.py b/tests/unit/test_config.py similarity index 100% rename from tests/test_config.py rename to tests/unit/test_config.py diff --git a/tox.ini b/tox.ini index 7f1f87f..5e5c469 100644 --- a/tox.ini +++ b/tox.ini @@ -2,10 +2,15 @@ envlist = py26, py27, py33 [testenv] -commands = python -m unittest discover --catch +commands = python -m unittest discover --catch tests/unit +deps = + mock + httpretty [testenv:py26] -commands = unit2 discover --catch +commands = unit2 discover --catch tests/unit deps = + mock + httpretty unittest2 discover