2018-05-09 00:55:45 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import util
|
|
|
|
|
|
|
|
|
|
|
|
class TestMedia(unittest.TestCase):
|
|
|
|
def runTest(self):
|
|
|
|
filename = '_test.txt'
|
|
|
|
data = 'test'
|
|
|
|
|
|
|
|
# storeMediaFile
|
2021-05-22 19:21:12 +00:00
|
|
|
util.invoke('storeMediaFile', filename=filename, data=data)
|
|
|
|
filename2 = util.invoke('storeMediaFile', filename=filename, data='testtest', deleteExisting=False)
|
|
|
|
self.assertNotEqual(filename2, filename)
|
2018-05-09 00:55:45 +00:00
|
|
|
|
|
|
|
# retrieveMediaFile (part 1)
|
|
|
|
media = util.invoke('retrieveMediaFile', filename=filename)
|
|
|
|
self.assertEqual(media, data)
|
|
|
|
|
2021-04-12 04:26:03 +00:00
|
|
|
names = util.invoke('getMediaFilesNames', pattern='_tes*.txt')
|
2021-05-22 19:21:12 +00:00
|
|
|
self.assertEqual(set(names), set([filename, filename2]))
|
2021-04-12 04:26:03 +00:00
|
|
|
|
2018-05-09 00:55:45 +00:00
|
|
|
# deleteMediaFile
|
|
|
|
util.invoke('deleteMediaFile', filename=filename)
|
|
|
|
|
|
|
|
# retrieveMediaFile (part 2)
|
|
|
|
media = util.invoke('retrieveMediaFile', filename=filename)
|
|
|
|
self.assertFalse(media)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|