Reorganise tests into unit and functional categories.
Tox (and hence Travis) only runs unit tests Functional tests can be run manually, with the default Python version
This commit is contained in:
parent
9319f903ac
commit
d3a4036817
15 changed files with 31 additions and 27 deletions
|
@ -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
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 910 B After Width: | Height: | Size: 910 B |
Before Width: | Height: | Size: 635 B After Width: | Height: | Size: 635 B |
0
tests/functional/api_versions/__init__.py
Normal file
0
tests/functional/api_versions/__init__.py
Normal file
|
@ -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
|
|
@ -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")
|
|
@ -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):
|
|
@ -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),
|
||||
]
|
|
@ -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")
|
|
@ -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
|
|
@ -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"):
|
9
tox.ini
9
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue