From 9cbbd1bd47066ca8f7ed73017d929d3b3c6721ff Mon Sep 17 00:00:00 2001 From: sneakypete81 Date: Sat, 20 Apr 2013 11:48:58 +0100 Subject: [PATCH] Run all tests at all API versions --- tests/api_versions/__init__.py | 0 tests/api_versions/test_v1.py | 10 ++++++++++ tests/api_versions/test_v2.py | 10 ++++++++++ tests/test_albums.py | 1 + tests/test_base.py | 12 ++++++++++-- tests/test_framework.py | 2 ++ tests/test_photos.py | 2 ++ tests/test_tags.py | 2 ++ 8 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/api_versions/__init__.py create mode 100644 tests/api_versions/test_v1.py create mode 100644 tests/api_versions/test_v2.py diff --git a/tests/api_versions/__init__.py b/tests/api_versions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/api_versions/test_v1.py b/tests/api_versions/test_v1.py new file mode 100644 index 0000000..92baabb --- /dev/null +++ b/tests/api_versions/test_v1.py @@ -0,0 +1,10 @@ +from tests import test_albums, test_photos, test_tags + +class TestAlbumsV1(test_albums.TestAlbums): + api_version = 1 + +class TestPhotosV1(test_photos.TestPhotos): + api_version = 1 + +class TestTagsV1(test_tags.TestTags): + api_version = 1 diff --git a/tests/api_versions/test_v2.py b/tests/api_versions/test_v2.py new file mode 100644 index 0000000..a6cfa4e --- /dev/null +++ b/tests/api_versions/test_v2.py @@ -0,0 +1,10 @@ +from tests import test_albums, test_photos, test_tags + +class TestAlbumsV2(test_albums.TestAlbums): + api_version = 2 + +class TestPhotosV2(test_photos.TestPhotos): + api_version = 2 + +class TestTagsV2(test_tags.TestTags): + api_version = 2 diff --git a/tests/test_albums.py b/tests/test_albums.py index 563660f..bc2de51 100644 --- a/tests/test_albums.py +++ b/tests/test_albums.py @@ -3,6 +3,7 @@ import openphoto import test_base class TestAlbums(test_base.TestBase): + testcase_name = "album API" def test_create_delete(self): """ Create an album then delete it """ diff --git a/tests/test_base.py b/tests/test_base.py index ad425b1..7563c46 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -22,6 +22,8 @@ class TestBase(unittest.TestCase): TEST_TAG = "test_tag" TEST_ALBUM = "test_album" MAXIMUM_TEST_PHOTOS = 4 # Never have more the 4 photos on the test server + testcase_name = "(unknown testcase)" + api_version = None def __init__(self, *args, **kwds): unittest.TestCase.__init__(self, *args, **kwds) @@ -36,9 +38,15 @@ class TestBase(unittest.TestCase): @classmethod def setUpClass(cls): """ Ensure there is nothing on the server before running any tests """ + if cls.api_version is None: + print "\nTesting Latest %s" % cls.testcase_name + else: + print "\nTesting %s v%d" % (cls.testcase_name, cls.api_version) + cls.client = openphoto.OpenPhoto(tokens.host, - tokens.consumer_key, tokens.consumer_secret, - tokens.token, tokens.token_secret) + tokens.consumer_key, tokens.consumer_secret, + tokens.token, tokens.token_secret, + cls.api_version) if cls.client.photos.list() != []: raise ValueError("The test server (%s) contains photos. " diff --git a/tests/test_framework.py b/tests/test_framework.py index 2627e9e..136e0ca 100644 --- a/tests/test_framework.py +++ b/tests/test_framework.py @@ -4,6 +4,8 @@ import openphoto import test_base class TestFramework(test_base.TestBase): + testcase_name = "framework" + def setUp(self): """Override the default setUp, since we don't need a populated database""" logging.info("\nRunning %s..." % self.id()) diff --git a/tests/test_photos.py b/tests/test_photos.py index 04e216d..0704220 100644 --- a/tests/test_photos.py +++ b/tests/test_photos.py @@ -3,6 +3,8 @@ import openphoto import test_base class TestPhotos(test_base.TestBase): + testcase_name = "photo API" + def test_delete_upload(self): """ Test photo deletion and upload """ # Delete one photo using the OpenPhoto class, passing in the id diff --git a/tests/test_tags.py b/tests/test_tags.py index 7f06ed2..aa3a821 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -3,6 +3,8 @@ import openphoto import test_base class TestTags(test_base.TestBase): + testcase_name = "tag API" + @unittest.expectedFailure # Tag create fails - Issue #927 # NOTE: the below has not been tested/debugged, since it fails at the first step def test_create_delete(self, tag_name="create_tag"):