aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/source/siteadmin/media-types.rst8
-rw-r--r--mediagoblin/api/views.py7
-rw-r--r--mediagoblin/media_types/video/processing.py2
-rw-r--r--mediagoblin/tests/test_api.py46
-rw-r--r--mediagoblin/tests/test_submission.py21
5 files changed, 80 insertions, 4 deletions
diff --git a/docs/source/siteadmin/media-types.rst b/docs/source/siteadmin/media-types.rst
index 70857c2d..38770638 100644
--- a/docs/source/siteadmin/media-types.rst
+++ b/docs/source/siteadmin/media-types.rst
@@ -69,6 +69,14 @@ The file-extension-based approach is used before the sniffing-based approach,
if the file-extension-based approach finds a match, the sniffing-based approach
will be skipped as it uses far more processing power.
+Configuring Media Types
+=======================
+
+Each media type has a ``config_spec.ini`` file with configurable
+options and comments explaining their intended side effect. For
+instance the ``video`` media type configuration can be found in
+``mediagoblin/media_types/video/config_spec.ini``.
+
Video
=====
diff --git a/mediagoblin/api/views.py b/mediagoblin/api/views.py
index dcd04cd6..74181fde 100644
--- a/mediagoblin/api/views.py
+++ b/mediagoblin/api/views.py
@@ -587,7 +587,12 @@ def feed_endpoint(request, outbox=None):
outbox = outbox.limit(limit)
# Offset (default: no offset - first <count> result)
- outbox = outbox.offset(request.args.get("offset", 0))
+ offset = request.args.get("offset", 0)
+ try:
+ offset = int(offset)
+ except ValueError:
+ offset = 0
+ outbox = outbox.offset(offset)
# Build feed.
for activity in outbox:
diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
index 0cdfbdce..ca3087a2 100644
--- a/mediagoblin/media_types/video/processing.py
+++ b/mediagoblin/media_types/video/processing.py
@@ -110,7 +110,7 @@ def get_tags(stream_info):
dt.get_year(), dt.get_month(), dt.get_day(), dt.get_hour(),
dt.get_minute(), dt.get_second(),
dt.get_microsecond()).isoformat()
- for k, v in tags.items():
+ for k, v in tags.copy().items():
# types below are accepted by json; others must not present
if not isinstance(v, (dict, list, six.string_types, int, float, bool,
type(None))):
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py
index 10bf08fe..33b93208 100644
--- a/mediagoblin/tests/test_api.py
+++ b/mediagoblin/tests/test_api.py
@@ -438,8 +438,8 @@ class TestAPI(object):
def test_read_feed(self, test_app):
""" Test able to read objects from the feed """
- response, data = self._upload_image(test_app, GOOD_JPG)
- response, data = self._post_image_to_feed(test_app, data)
+ response, image_data = self._upload_image(test_app, GOOD_JPG)
+ response, data = self._post_image_to_feed(test_app, image_data)
uri = "/api/user/{0}/feed".format(self.active_user.username)
with self.mock_oauth():
@@ -462,6 +462,48 @@ class TestAPI(object):
assert feed["items"][0]["object"]["objectType"] == "image"
assert feed["items"][0]["object"]["id"] == data["object"]["id"]
+ default_limit = 20
+ items_count = default_limit * 2
+ for i in range(items_count):
+ response, image_data = self._upload_image(test_app, GOOD_JPG)
+ self._post_image_to_feed(test_app, image_data)
+ items_count += 1 # because there already is one
+
+ #
+ # default returns default_limit items
+ #
+ with self.mock_oauth():
+ response = test_app.get(uri)
+ feed = json.loads(response.body.decode())
+ assert len(feed["items"]) == default_limit
+
+ #
+ # silentely ignore count and offset that that are
+ # not a number
+ #
+ with self.mock_oauth():
+ response = test_app.get(uri + "?count=BAD&offset=WORSE")
+ feed = json.loads(response.body.decode())
+ assert len(feed["items"]) == default_limit
+
+ #
+ # if offset is less than default_limit items
+ # from the end of the feed, return less than
+ # default_limit
+ #
+ with self.mock_oauth():
+ near_the_end = items_count - default_limit / 2
+ response = test_app.get(uri + "?offset=%d" % near_the_end)
+ feed = json.loads(response.body.decode())
+ assert len(feed["items"]) < default_limit
+
+ #
+ # count=5 returns 5 items
+ #
+ with self.mock_oauth():
+ response = test_app.get(uri + "?count=5")
+ feed = json.loads(response.body.decode())
+ assert len(feed["items"]) == 5
def test_read_another_feed(self, test_app):
""" Test able to read objects from someone else's feed """
diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py
index 0ec49ec7..9a4f4645 100644
--- a/mediagoblin/tests/test_submission.py
+++ b/mediagoblin/tests/test_submission.py
@@ -52,6 +52,21 @@ FORM_CONTEXT = ['mediagoblin/submit/start.html', 'submit_form']
REQUEST_CONTEXT = ['mediagoblin/user_pages/user.html', 'request']
+SKIP_AUDIO = False
+SKIP_VIDEO = False
+
+try:
+ import gi.repository.Gst
+except ImportError:
+ SKIP_AUDIO = True
+ SKIP_VIDEO = True
+
+try:
+ import scikits.audiolab
+except ImportError:
+ SKIP_AUDIO = True
+
+
class TestSubmission:
@pytest.fixture(autouse=True)
def setup(self, test_app):
@@ -389,14 +404,20 @@ class TestSubmission:
media = self.check_media(None, {"title": u"With GPS data"}, 1)
assert media.get_location.position["latitude"] == 59.336666666666666
+ @pytest.mark.skipif(SKIP_AUDIO,
+ reason="Dependencies for audio not met")
def test_audio(self):
with create_av(make_audio=True) as path:
self.check_normal_upload('Audio', path)
+ @pytest.mark.skipif(SKIP_VIDEO,
+ reason="Dependencies for video not met")
def test_video(self):
with create_av(make_video=True) as path:
self.check_normal_upload('Video', path)
+ @pytest.mark.skipif(SKIP_AUDIO or SKIP_VIDEO,
+ reason="Dependencies for audio or video not met")
def test_audio_and_video(self):
with create_av(make_audio=True, make_video=True) as path:
self.check_normal_upload('Audio and Video', path)