Emmanuel Cazenave avatar Emmanuel Cazenave committed eeb2675

Test the 'process_finished' notification in 'failure' in a code producer.

Comments (0)

Files changed (2)

pyf/componentized/tests/data/test_listen_failure_in_a_code_producer.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+  <process>
+    <node type="producer" name="producer1" from="code">
+      <code>
+        <![CDATA[
+
+from pyf.componentized.tests.utils import TestException
+
+def raise_exception(finished_status):
+    if finished_status == 'failure':
+        raise TestException()
+
+add_listener('process_finished', raise_exception)
+
+
+class Dummy(object):
+    pass
+
+def get_source():
+    for index in range(0, 10):
+        yield Dummy()
+    yield aa
+    
+         
+        ]]>
+      </code>
+      <children>
+	<link name="consumer1" />
+      </children>
+    </node>
+    <node type="consumer" name="consumer1" from="code">
+      <code>
+        <![CDATA[
+
+def consume(items):
+    for item in items:
+        yield True
+
+        ]]>
+      </code>
+    </node>
+  </process>
+</config>
+

pyf/componentized/tests/test_components.py

     manager.process()
 
 
-    
+@raises(TestException)
+def test_listen_failure_in_a_code_producer():
+    """Test that a code producer component is notified of the 'process_finished' event, 
+    with the 'failure' status when a processed does not finish properly.
+    """
+    test_file = "test_listen_failure_in_a_code_producer.xml"
+    network_file = open(os.path.join(DATADIR, test_file), 'r')
+    network_xml = network_file.read()
+    network_file.close()
+    manager = Manager(ET.fromstring(network_xml))
+    manager.process()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.