tests for controller.viewinterface.fax added devel
authorSandro Knauß <knauss@netzguerilla.net>
Tue, 28 Feb 2012 01:44:11 +0100
branchdevel
changeset 198 85ede27b1add
parent 197 73b11797781b
child 199 1bcca1a40769
tests for controller.viewinterface.fax added
iro/controller/viewinterface.py
iro/model/message.py
tests/viewinterface.py
--- a/iro/controller/viewinterface.py	Tue Feb 28 01:19:15 2012 +0100
+++ b/iro/controller/viewinterface.py	Tue Feb 28 01:44:11 2012 +0100
@@ -85,7 +85,7 @@
         Keywords:
         apikey[string]: Der API Key
         subject[string]: Der Betreff
-        fax[string]: Das PDF base64 kodiert
+        fax[string]: Der base64 kodierte content
         recipients[list]: Eine Liste von Emfänger-Nummern (gemäß ITU-T E.123)
         route[string|list]: Route über den geschickt werden soll, 
                             oder eine Liste von Routen, um Fallbacks anzugeben
@@ -94,8 +94,11 @@
         id[hash]: Die ID des Auftrages
 
         '''
-        job = createJob(recipients, Fax(subject, fax), info, route)
-        return job.id
+        d = createJob(user, recipients, Fax(subject, fax), route, info)
+        def ret(job):
+            return job.dbjob
+        d.addCallback(ret)
+        return d
 
     @validate(kwd="recipients",func=vEmail)
     @validate(kwd="frm",func=vEmail)
--- a/iro/model/message.py	Tue Feb 28 01:19:15 2012 +0100
+++ b/iro/model/message.py	Tue Feb 28 01:44:11 2012 +0100
@@ -28,7 +28,7 @@
 
 
 class Fax(Message):
-    def __init__(self,header,cont,attachments):
+    def __init__(self,header,cont,attachments=[]):
         Message.__init__(self,cont, typ="fax")
         self.header=header
         self.attachments=attachments
--- a/tests/viewinterface.py	Tue Feb 28 01:19:15 2012 +0100
+++ b/tests/viewinterface.py	Tue Feb 28 01:44:11 2012 +0100
@@ -231,6 +231,20 @@
         self.assertEqual(exJob.message,Mail("sub",'hey body!','frm@t.de'))
         self.assertEqual(taskPool.pool.q.qsize(),1)
 
+    @inlineCallbacks
     def testFax(self):
-        pass
-    testFax.todo = "To implement"
+        with self.session() as session:
+            u = User(name='test',apikey='abcdef123456789')
+            o = Offer(name='b',provider="sipgate",route="b",typ="fax")
+            u.rights.append(Userright(o))
+            session.add(u)
+        
+        jobid = yield Interface().fax('abcdef123456789','subject', 'blublbubblu',['0123325456'],['b'])
+       
+        with self.session() as session:
+            u = session.merge(u)
+            job = u.job(jobid)
+            exJob = job.extend
+        
+        self.assertEqual(exJob.message,Fax("subject","blublbubblu"))
+        self.assertEqual(taskPool.pool.q.qsize(),1)