Advertisement
Guest User

Untitled

a guest
Jun 27th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.32 KB | None | 0 0
  1. # -*- test-case-name: flumotion.test.test_component_httpstreamer -*-
  2. # vi:si:et:sw=4:sts=4:ts=4
  3.  
  4. # Flumotion - a streaming media server
  5. # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L.
  6. # Copyright (C) 2010,2011 Flumotion Services, S.A.
  7. # All rights reserved.
  8. #
  9. # This file may be distributed and/or modified under the terms of
  10. # the GNU Lesser General Public License version 2.1 as published by
  11. # the Free Software Foundation.
  12. # This file is distributed without any warranty; without even the implied
  13. # warranty of merchantability or fitness for a particular purpose.
  14. # See "LICENSE.LGPL" in the source distribution for more information.
  15. #
  16. # Headers in this file shall remain intact.
  17.  
  18. from twisted.trial import unittest
  19.  
  20. from flumotion.common import testsuite
  21. from flumotion.component.consumers.httpstreamer import httpstreamer
  22.  
  23. attr = testsuite.attr
  24.  
  25. CONFIG = {
  26.     'feed': [],
  27.     'name': 'http-video',
  28.     'parent': 'default',
  29.     'eater': {'default': [('muxer-video:default', 'default')]},
  30.     'source': ['muxer-video:default'],
  31.     'avatarId': '/default/http-video',
  32.     'clock-master': None,
  33.     'plugs': {
  34.         'flumotion.component.plugs.streamdata.StreamDataProviderPlug': [],
  35.         'flumotion.component.plugs.request.RequestLoggerPlug': [],
  36.     },
  37.     'type': 'http-streamer',
  38. }
  39.  
  40.  
  41. class StreamerTestCase(testsuite.TestCase):
  42.  
  43.     slow = True
  44.  
  45.     properties = {}
  46.     config = CONFIG
  47.  
  48.     def setUp(self):
  49.         config = self.getConfig()
  50.         config['properties'] = self.properties.copy()
  51.         self.component = httpstreamer.MultifdSinkStreamer(config)
  52.  
  53.     def tearDown(self):
  54.         return self.component.stop()
  55.  
  56.     def getConfig(self):
  57.         # test classes can override this to change/extend config
  58.         return self.config.copy()
  59.  
  60.  
  61. class TestStreamDataNoPlug(StreamerTestCase):
  62.  
  63.     def __init__(self, banana):
  64.         StreamerTestCase.__init__(self)
  65.  
  66.     def testGetStreamData(self):
  67.         streamData = self.component.getStreamData()
  68.         # there's no plug, so we get defaults
  69.         self.assertEquals(streamData['protocol'], 'HTTP')
  70.         self.assertEquals(streamData['description'], 'Flumotion Stream')
  71.         self.failUnless(streamData['url'].startswith('http://'))
  72.  
  73.  
  74. class TestStreamDataPlug(StreamerTestCase):
  75.  
  76.     def __init__(self, banana):
  77.         StreamerTestCase.__init__(self)
  78.  
  79.     def getConfig(self):
  80.         config = CONFIG.copy()
  81.         sType = 'flumotion.component.plugs.streamdata.StreamDataProviderPlug'
  82.         pType = 'streamdataprovider-example'
  83.         config['plugs'] = {sType: [
  84.             {
  85.                 'entries': {
  86.                     'default': {
  87.                         'module-name': 'flumotion.component.plugs.streamdata',
  88.                         'function-name': 'StreamDataProviderExamplePlug',
  89.                     }
  90.                 }
  91.             },
  92.         ]}
  93.         return config
  94.  
  95.     def testGetStreamData(self):
  96.         streamData = self.component.getStreamData()
  97.         self.assertEquals(streamData['protocol'], 'HTTP')
  98.         self.assertEquals(streamData['description'], 'Flumotion Stream')
  99.         self.failUnless(streamData['url'].startswith('http://'))
  100.     # plug is started before component can do getUrl
  101.     testGetStreamData.skip = 'See #1137'
  102.  
  103.  
  104. if __name__ == '__main__':
  105.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement