예제 #1
0
 def testEmptyIdInDeleteNotAllowed(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals = {}
     v = Venturi()
     try:
         list(compose(v.delete('')))
         self.fail("Should raise an exception")
     except ValueError, e:
         self.assertEquals("Empty identifier not allowed.", str(e))
예제 #2
0
 def testEmptyIdInDeleteNotAllowed(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals={}
     v = Venturi()
     try:
         list(compose(v.delete('')))
         self.fail("Should raise an exception")
     except ValueError, e:
         self.assertEquals("Empty identifier not allowed.", str(e))
예제 #3
0
 def testEmptyIdInAddNotAllowed(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals={}
     inputEvent = fromstring("""<document><part name="partone">&lt;some&gt;t€xt&lt;/some&gt;\n\n\n\n</part><part name="parttwo"><second>t€xt</second>\n\n\n\n</part></document>""")
     v = Venturi()
     try:
         list(compose(v.add('', 'document', inputEvent)))
         self.fail("Should raise an exception")
     except ValueError, e:
         self.assertEquals("Empty identifier not allowed.", str(e))
예제 #4
0
 def testDeleteAlsoSetsIdOnTransaction(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals = {}
     v = Venturi(should=[{
         'partname': 'PARTNAME',
         'xpath': '/document'
     }],
                 could=[])
     list(compose(v.delete(identifier='identifier')))
     self.assertEquals('identifier', __callstack_var_tx__.locals['id'])
예제 #5
0
 def testEmptyIdInAddNotAllowed(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals = {}
     inputEvent = fromstring(
         """<document><part name="partone">&lt;some&gt;t€xt&lt;/some&gt;\n\n\n\n</part><part name="parttwo"><second>t€xt</second>\n\n\n\n</part></document>"""
     )
     v = Venturi()
     try:
         list(compose(v.add('', 'document', inputEvent)))
         self.fail("Should raise an exception")
     except ValueError, e:
         self.assertEquals("Empty identifier not allowed.", str(e))
예제 #6
0
    def testDeleteIsAsynchronous(self):
        __callstack_var_tx__ = CallTrace('Transaction')
        __callstack_var_tx__.locals={}
        observer = CallTrace('observer')
        callable = lambda: None
        observer.returnValues['delete'] = (f for f in [callable])
        v = Venturi()
        v.addObserver(observer)

        result = list(compose(v.delete(identifier='identifier')))

        self.assertEqual([callable], result)
        self.assertEqual(['delete'], [m.name for m in observer.calledMethods])
예제 #7
0
    def testDeleteIsAsynchronous(self):
        __callstack_var_tx__ = CallTrace('Transaction')
        __callstack_var_tx__.locals={}
        observer = CallTrace('observer')
        callable = lambda: None
        observer.returnValues['delete'] = (f for f in [callable])
        v = Venturi()
        v.addObserver(observer)

        result = list(compose(v.delete(identifier='identifier')))

        self.assertEquals([callable], result)
        self.assertEquals(['delete'], [m.name for m in observer.calledMethods])
예제 #8
0
def createVenturiHelix(should, could, *observers, **kwargs):
    return be(
        (Observable(),
            (TransactionScope('document'),
                (Venturi(
                        should=should,
                        could=could,
                        namespaces=kwargs.get('namespaces', None)),)
                    + tuple((observer,) for observer in observers)
            )
        )
    )
예제 #9
0
 def testDeprecatedPartsSpecification(self):
     with warnings.catch_warnings():
         warnings.simplefilter("default")
         with stderr_replaced() as s:
             venturi = Venturi(should=[('partname', '/x/path')])
             self.assertTrue("Please use {'partname'" in s.getvalue())
예제 #10
0
 def testDeleteAlsoSetsIdOnTransaction(self):
     __callstack_var_tx__ = CallTrace('Transaction')
     __callstack_var_tx__.locals={}
     v = Venturi(should=[{'partname': 'PARTNAME', 'xpath': '/document'}],could=[])
     list(compose(v.delete(identifier='identifier')))
     self.assertEquals('identifier', __callstack_var_tx__.locals['id'])