2
# Jason Gerard DeRose <jderose@novacut.com>
4
# dmedia: distributed media library
5
# Copyright (C) 2011 Jason Gerard DeRose <jderose@novacut.com>
7
# This file is part of `dmedia`.
9
# `dmedia` is free software: you can redistribute it and/or modify it under the
10
# terms of the GNU Affero General Public License as published by the Free
11
# Software Foundation, either version 3 of the License, or (at your option) any
14
# `dmedia` is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19
# You should have received a copy of the GNU Affero General Public License along
20
# with `dmedia`. If not, see <http://www.gnu.org/licenses/>.
23
Unit tests for the `dmedia.backends.s3` module.
26
from unittest import TestCase
28
from dmedia.backends import s3
31
class TestS3Backend(TestCase):
35
inst = self.klass({'_id': 'foo', 'bucket': 'bar'})
36
self.assertEqual(inst.bucketname, 'bar')
37
self.assertEqual(inst._bucket, None)
40
inst = self.klass({'_id': 'foo', 'bucket': 'bar'})
41
self.assertEqual(repr(inst), "S3Backend('foo')")
44
# Test with include_ext = False
45
inst = self.klass({'_id': 'foo', 'bucket': 'bar'})
47
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'),
48
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'
51
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O', ext=None),
52
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'
55
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O', ext='mov'),
56
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'
59
# Test with include_ext = True
60
inst = self.klass({'_id': 'foo', 'bucket': 'bar', 'include_ext': True})
62
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'),
63
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'
66
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O', ext=None),
67
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O'
70
inst.key('ZR765XWSF6S7JQHLUI4GCG5BHGPE252O', ext='mov'),
71
'ZR765XWSF6S7JQHLUI4GCG5BHGPE252O.mov'
74
def test_bucket(self):
75
inst = self.klass({'_id': 'foo', 'bucket': 'bar'})
76
inst._bucket = 'whatever'
77
self.assertEqual(inst.bucket, 'whatever')