msmith - in flumotion/trunk: .
flumotion/component/producers/playlist flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Wed May 16 12:54:11 CEST 2007
Author: msmith
Date: Wed May 16 12:54:09 2007
New Revision: 4959
Added:
flumotion/trunk/flumotion/test/test_component_playlist.py
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py
flumotion/trunk/flumotion/test/Makefile.am
Log:
* flumotion/test/Makefile.am:
* flumotion/test/test_component_playlist.py:
First round of simple tests for playlist stuff
* flumotion/component/producers/playlist/playlistparser.py:
First bug fixed due to tests of playlist stuff.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Wed May 16 12:54:09 2007
@@ -1,5 +1,14 @@
2007-05-16 Michael Smith <msmith at fluendo.com>
+ * flumotion/test/Makefile.am:
+ * flumotion/test/test_component_playlist.py:
+ First round of simple tests for playlist stuff
+
+ * flumotion/component/producers/playlist/playlistparser.py:
+ First bug fixed due to tests of playlist stuff.
+
+2007-05-16 Michael Smith <msmith at fluendo.com>
+
* flumotion/component/producers/playlist/playlist.py:
* flumotion/component/producers/playlist/playlistparser.py:
Refactor playlist stuff to make it more testable. Tests to come.
Modified: flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py
==============================================================================
--- flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py (original)
+++ flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py Wed May 16 12:54:09 2007
@@ -70,6 +70,9 @@
continue
if item.prev:
item.prev.next = item.next
+ else:
+ self.items = item.next
+
if item.next:
item.next.prev = item.prev
self.producer.unscheduleItem(item)
Modified: flumotion/trunk/flumotion/test/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/test/Makefile.am (original)
+++ flumotion/trunk/flumotion/test/Makefile.am Wed May 16 12:54:09 2007
@@ -33,6 +33,7 @@
test_component_feed.py \
test_component_httpserver.py \
test_component_httpstreamer.py \
+ test_component_playlist.py \
test_config.py \
test_credentials.py \
test_dag.py \
Added: flumotion/trunk/flumotion/test/test_component_playlist.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/test/test_component_playlist.py Wed May 16 12:54:09 2007
@@ -0,0 +1,88 @@
+# -*- Mode: Python; test-case-name: flumotion.test.test_component_httpstreamer -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+from twisted.trial import unittest
+
+import common
+
+from twisted.python import failure
+from twisted.internet import defer
+
+from flumotion.component.producers.playlist import playlistparser
+
+class FakeProducer():
+ def scheduleItem(self, item):
+ pass
+
+ def unscheduleItem(self, item):
+ pass
+
+class TestPlaylist(unittest.TestCase):
+ def setUp(self):
+ producer = FakeProducer()
+
+ self.playlist = playlistparser.Playlist(producer)
+
+ def checkItems(self, expectedlen):
+ l = 0
+ cur = self.playlist.items
+ if cur:
+ self.assertEquals(cur.prev, None)
+
+ while cur:
+ l += 1
+ # Check consistency of links
+ if cur.next:
+ self.assertEquals(cur, cur.next.prev)
+ cur = cur.next
+
+ self.assertEquals(l, expectedlen)
+
+ def testAddSingleItem(self):
+ self.playlist.addItem(None, 0, "file:///testuri", 0, 100, True, True)
+
+ self.assertTrue(self.playlist._itemsById.has_key(None))
+ self.assertEquals(len(self.playlist._itemsById[None]), 1)
+
+ self.checkItems(1)
+ pass
+
+ def testAddRemoveSingleItem(self):
+ self.playlist.addItem('id1', 0, "file:///testuri", 0, 100, True, True)
+ self.playlist.removeItems('id1')
+
+ self.assertFalse(self.playlist._itemsById.has_key('id1'))
+
+ self.checkItems(0)
+
+ def testAddRemoveMultipleItems(self):
+ self.playlist.addItem('id1', 0, "file:///testuri", 0, 100, True, True)
+ self.playlist.addItem('id1', 100, "file:///testuri2", 0, 100, True, True)
+ self.playlist.addItem('id2', 200, "file:///testuri2", 0, 100, True, True)
+ self.checkItems(3)
+
+ self.playlist.removeItems('id1')
+ self.assertFalse(self.playlist._itemsById.has_key('id1'))
+ self.assertTrue(self.playlist._itemsById.has_key('id2'))
+ self.checkItems(1)
+
+if __name__ == '__main__':
+ unittest.main()
More information about the flumotion-commit
mailing list