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))
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))
def testEmptyIdInAddNotAllowed(self): __callstack_var_tx__ = CallTrace('Transaction') __callstack_var_tx__.locals={} inputEvent = fromstring("""<document><part name="partone"><some>t€xt</some>\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))
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'])
def testEmptyIdInAddNotAllowed(self): __callstack_var_tx__ = CallTrace('Transaction') __callstack_var_tx__.locals = {} inputEvent = fromstring( """<document><part name="partone"><some>t€xt</some>\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))
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])
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])
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) ) ) )
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())
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'])