source: orange/Orange/OrangeCanvas/scheme/tests/test_readwrite.py @ 11101:e5aa7c1c5b23

Revision 11101:e5aa7c1c5b23, 1.3 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added scheme package, containing the scheme graph workflow data structure/model.

Line 
1"""Test read write
2"""
3from ...gui import test
4from ...registry import global_registry
5
6from .. import Scheme, SchemeNode, SchemeLink
7from ..readwrite import scheme_to_ows_stream, parse_scheme
8
9
10class TestReadWrite(test.QAppTestCase):
11    def test_io(self):
12        from StringIO import StringIO
13        reg = global_registry()
14
15        base = "Orange.OrangeWidgets"
16        file_desc = reg.widget(base + ".Data.OWFile.OWFile")
17        discretize_desc = reg.widget(base + ".Data.OWDiscretize.OWDiscretize")
18        bayes_desc = reg.widget(base + ".Classify.OWNaiveBayes.OWNaiveBayes")
19
20        scheme = Scheme()
21        file_node = SchemeNode(file_desc)
22        discretize_node = SchemeNode(discretize_desc)
23        bayes_node = SchemeNode(bayes_desc)
24
25        scheme.add_node(file_node)
26        scheme.add_node(discretize_node)
27        scheme.add_node(bayes_node)
28
29        scheme.add_link(SchemeLink(file_node, "Data",
30                                   discretize_node, "Data"))
31
32        scheme.add_link(SchemeLink(discretize_node, "Data",
33                                   bayes_node, "Data"))
34
35        stream = StringIO()
36        scheme_to_ows_stream(scheme, stream)
37
38        stream.seek(0)
39
40        scheme_1 = parse_scheme(Scheme(), stream)
41
42        self.assertTrue(len(scheme.nodes) == len(scheme_1.nodes))
43        self.assertTrue(len(scheme.links) == len(scheme_1.links))
Note: See TracBrowser for help on using the repository browser.