Commits

Guido Draheim  committed b2196ea

more tests

  • Participants
  • Parent commits 069cd0f

Comments (0)

Files changed (2)

File src/dvbcronrecording/computer.py

     def set_adapters_from_channels_list(self, channelslist):
         for entry in channelslist:
             channelname = entry.channelname
-            adapter = entry.adapter
+            adapter = ustar(entry.adapter)
             if channelname not in self._adapters:
                 self._adapters[channelname] = []
             if adapter not in self._adapters[channelname]:
         for adapters in self._adapters.values():
             for adapter in adapters:
                 if adapter and adapter not in adapterlist:
-                    adapterlist += [ adapter ]
+                    adapterlist += [ ustar(adapter) ]
         self._adapterlist = adapterlist
     def adapterlist(self):
         """ get the union of available adapters used in configured channels """

File src/tests/computer_test.py

         self.assertEqual(0.3, self.computer.rankup_value)
         self.assertEqual(0.5, self.computer.onlydate_rankup)
     def test_02_channels(self):
-        channellist = [Channel("3sat",1),Channel("ard",0), Channel("ard",1)]
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
         self.computer.set_adapters_from_channels_list(channellist)
-        self.assertTrue(1 in self.computer.adapterlist())
-        self.assertEqual([1], self.computer.adapters("3sat"))
-        self.assertEqual([0, 1], self.computer.adapters("ard"))
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        self.assertEqual([u"1"], self.computer.adapters("3sat"))
+        self.assertEqual([u"0", u"1"], self.computer.adapters("arte"))
     def test_03_entries(self):
-        a = Entry("ard","ard1","22:30","23:30","0", "6", "", "ok")
+        a1 = Entry("arte","A1","22:30","23:30","0", "6", "", "ok")
         req = Request(Locale("de"))
-        res = self.computer.plan4(req, [a])
+        res = self.computer.plan4(req, [a1])
         self.logg.info("RESULT:%s", res)
         E = u"""
-{[{  [22:30-23:30]+0 ard@0 (* 1,2,3,4,5,6,7,8,9,10,11,12 6) 'ard1' }]}"""
-        self.assertEqual(unicode(res), E)
+{[{  [22:30-23:30]+0 arte@0 (* 1,2,3,4,5,6,7,8,9,10,11,12 6) 'A1' }]}"""
+        self.assertEqual(E, unicode(res))
     def test_04_entries(self):
-        a = Entry("ard","ard1","22:30","23:30","0", "", "22.04.", "ok")
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
         req = Request(Locale("de"))
-        res = self.computer.plan4(req, [a])
+        res = self.computer.plan4(req, [a1])
         self.logg.info("RESULT:%s", res)
         E = u"""
-{[{  [22:30-23:30]+0 ard@0 (22 4 6) 'ard1' }]}"""
-        self.assertEqual(unicode(res), E)
+{[{  [22:30-23:30]+0 arte@0 (22 4 6) 'A1' }]}"""
+        self.assertEqual(E, unicode(res))
     def test_10_2entries_samegroupandcontinue(self):
-        a = Entry("ard","ard1","22:30","23:30","0", "", "22.04.", "ok")
-        b = Entry("ard","ard1","23:30","00:30","0", "", "22.04.", "ok")
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("arte","A2","23:30","00:30","0", "", "22.04.", "ok")
         req = Request(Locale("de"))
-        res = self.computer.plan4(req, [a, b])
+        res = self.computer.plan4(req, [a1, a2])
         self.logg.info("RESULT:%s", res)
         E = u"""
-{[{  [22:30-23:30]+0 ard@0 (22 4 6) 'ard1' },
-  {  [23:30-00:30]+0 ard@0 (22 4 6) 'ard1' }]}"""
-        self.assertEqual(unicode(res), E)
+{[{  [22:30-23:30]+0 arte@0 (22 4 6) 'A1' },
+  {  [23:30-00:30]+0 arte@0 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
     def test_11_2entries_differentgroups(self):
-        a = Entry("ard","ard1","22:30","23:30","0", "", "22.04.", "ok")
-        b = Entry("ard","ard1","23:33","00:33","0", "", "22.04.", "ok")
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("arte","A2","23:33","00:33","0", "", "22.04.", "ok")
         req = Request(Locale("de"))
-        res = self.computer.plan4(req, [a, b])
+        res = self.computer.plan4(req, [a1, a2])
         self.logg.info("RESULT:%s", res)
         E = u"""
-{[{  [22:30-23:30]+0 ard@0 (22 4 6) 'ard1' }],
- [{  [23:33-00:33]+0 ard@0 (22 4 6) 'ard1' }]}"""
-        self.assertEqual(unicode(res), E)
+{[{  [22:30-23:30]+0 arte@0 (22 4 6) 'A1' }],
+ [{  [23:33-00:33]+0 arte@0 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_20_2entries_differentchannels0(self):
+        channellist = [Channel("3sat",0),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("3sat","A2","22:33","23:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:30-23:30]+0 arte@1 (22 4 6) 'A1' }],
+ [{  [22:33-23:33]+0 3sat@0 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_21_2entries_differentchannels1(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("3sat","A2","22:33","23:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:30-23:30]+0 arte@0 (22 4 6) 'A1' }],
+ [{  [22:33-23:33]+0 3sat@1 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_23_3entries_differentchannels0(self):
+        channellist = [Channel("3sat",0),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("3sat","A2","22:33","23:33","0", "", "22.04.", "ok")
+        a3 = Entry("3sat","A3","23:33","00:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:30-23:30]+0 arte@1 (22 4 6) 'A1' }],
+ [{  [22:33-23:33]+0 3sat@0 (22 4 6) 'A2' },
+  {  [23:33-00:33]+0 3sat@0 (22 4 6) 'A3' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_24_3entries_differentchannels1(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:30","23:30","0", "", "22.04.", "ok")
+        a2 = Entry("3sat","A2","22:33","23:33","0", "", "22.04.", "ok")
+        a3 = Entry("3sat","A3","23:33","00:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:30-23:30]+0 arte@0 (22 4 6) 'A1' }],
+ [{  [22:33-23:33]+0 3sat@1 (22 4 6) 'A2' },
+  {  [23:33-00:33]+0 3sat@1 (22 4 6) 'A3' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_25_3entries_differentchannels_inside1(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("3sat","A1","22:33","23:33","0", "", "22.04.", "ok")
+        a2 = Entry("arte","A2","23:30","00:30","0", "", "22.04.", "ok")
+        a3 = Entry("3sat","A3","23:33","00:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:33-23:33]+0 3sat@1 (22 4 6) 'A1' },
+  {  [23:33-00:33]+0 3sat@1 (22 4 6) 'A3' }],
+ [{  [23:30-00:30]+0 arte@0 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_26_3entries_differentchannels_inside2(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:33","23:33","0", "", "22.04.", "ok")
+        a2 = Entry("3sat","A2","23:30","00:30","0", "", "22.04.", "ok")
+        a3 = Entry("arte","A3","23:33","00:33","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:33-23:33]+0 arte@0 (22 4 6) 'A1' },
+  {  [23:33-00:33]+0 arte@0 (22 4 6) 'A3' }],
+ [{  [23:30-00:30]+0 3sat@1 (22 4 6) 'A2' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_27_3entries_differentchannels_atend(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:33","23:33","0", "", "22.04.", "ok")
+        a2 = Entry("arte","A2","23:33","00:33","0", "", "22.04.", "ok")
+        a3 = Entry("3sat","A3","23:50","00:50","0", "", "22.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:33-23:33]+0 arte@0 (22 4 6) 'A1' },
+  {  [23:33-00:33]+0 arte@0 (22 4 6) 'A2' }],
+ [{  [23:50-00:50]+0 3sat@1 (22 4 6) 'A3' }]}"""
+        self.assertEqual(E, unicode(res))
+    def test_28_3entries_differentchannels_nextday(self):
+        channellist = [Channel("3sat",1),Channel("arte",0), Channel("arte",1)]
+        self.computer.set_adapters_from_channels_list(channellist)
+        self.assertTrue(u"1" in self.computer.adapterlist())
+        a1 = Entry("arte","A1","22:33","23:33","0", "", "22.04.", "ok")
+        a2 = Entry("arte","A2","23:33","00:33","0", "", "22.04.", "ok")
+        a3 = Entry("3sat","A3","00:10","01:10","0", "", "23.04.", "ok")
+        req = Request(Locale("de"))
+        res = self.computer.plan4(req, [a1, a2, a3])
+        self.logg.info("RESULT:%s", res)
+        E = u"""
+{[{  [22:33-23:33]+0 arte@0 (22 4 6) 'A1' },
+  {  [23:33-00:33]+0 arte@0 (22 4 6) 'A2' }],
+ [{  [00:10-01:10]+0 3sat@1 (23 4 0) 'A3' }]}"""
+        self.assertEqual(E, unicode(res))
 
 if __name__ == "__main__":
     import sys