Add OPENPHOTO_TEST_SERVER_API env var

To allow testing to be restricted to a specific maximum API version.
This allows new API tests to be skipped for old servers.
This commit is contained in:
sneakypete81 2013-05-06 21:53:22 +01:00
parent c4ea338f49
commit 034f24db4c
6 changed files with 26 additions and 5 deletions

View file

@ -61,3 +61,15 @@ Ensure there are:
**TearDownClass:**
Remove all photos, tags and albums
### Testing old servers
By default, all currently supported API versions will be tested.
It's useful to test servers that only support older API versions.
To restrict the testing to a specific maximum API version, use the
``OPENPHOTO_TEST_SERVER_API`` environment variable.
For example, to restrict testing to APIv1 and APIv2:
export OPENPHOTO_TEST_SERVER_API=2

View file

@ -7,6 +7,5 @@ class TestAlbumsV1(test_albums.TestAlbums):
class TestPhotosV1(test_photos.TestPhotos):
api_version = 1
# The tag API didn't work at v1 - see frontend issue #927
# class TestTagsV1(test_tags.TestTags):
# api_version = 1
class TestTagsV1(test_tags.TestTags):
api_version = 1

View file

@ -1,10 +1,14 @@
from tests import test_albums, test_photos, test_tags
import unittest
from tests import test_base, test_albums, test_photos, test_tags
@unittest.skipIf(test_base.get_test_server_api() < 2, "Don't test future API versions")
class TestAlbumsV2(test_albums.TestAlbums):
api_version = 2
@unittest.skipIf(test_base.get_test_server_api() < 2, "Don't test future API versions")
class TestPhotosV2(test_photos.TestPhotos):
api_version = 2
@unittest.skipIf(test_base.get_test_server_api() < 2, "Don't test future API versions")
class TestTagsV2(test_tags.TestTags):
api_version = 2

View file

@ -1,4 +1,5 @@
import unittest
import os
import logging
import openphoto
@ -16,6 +17,9 @@ except ImportError:
"********************************************************************\n")
raise
def get_test_server_api():
return int(os.getenv("OPENPHOTO_TEST_SERVER_API", openphoto.LATEST_API_VERSION))
class TestBase(unittest.TestCase):
TEST_TITLE = "Test Image - delete me!"
TEST_TAG = "test_tag"

View file

@ -27,7 +27,7 @@ class TestFramework(test_base.TestBase):
def test_specified_api_version(self):
# For all API versions >0, we get a generic hello world message
for api_version in range(1, openphoto.LATEST_API_VERSION + 1):
for api_version in range(1, test_base.get_test_server_api() + 1):
client = self.create_client_from_base(api_version=api_version)
result = client.get("hello.json")
self.assertEqual(result['message'], "Hello, world!")

View file

@ -2,6 +2,8 @@ import unittest
import openphoto
import test_base
@unittest.skipIf(test_base.get_test_server_api() == 1,
"The tag API didn't work at v1 - see frontend issue #927")
class TestTags(test_base.TestBase):
testcase_name = "tag API"