~daniel-nichter/boots/vertical-output

« back to all changes in this revision

Viewing changes to tests/boots/lib/lingos/lingo_tests.py

  • Committer: Max Goodman
  • Date: 2010-03-29 23:47:14 UTC
  • Revision ID: chromakode@gmail.com-20100329234714-e6jy51kq2j79ev3i
Fix up unit tests, handle warnings in api.Server objects, and add --quiet option to suppress warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from boots.api.nodes.node import NodeGraph, SyncNode
27
27
from boots.app import client_config
28
28
from boots.lib import console
29
 
from boots.lib.lingos import lingo, bash_external, lisp, piped_sql, python, sql
 
29
from boots.lib.lingos import lingo, bash_external, piped_sql, python, sql
30
30
import os
31
31
import tempfile
32
32
 
43
43
 
44
44
class LingoBaseTester(boots_unit_test.BootsBaseTester):
45
45
    def setUp(self):
46
 
        self.config = client_config.ClientConfig()
47
 
        self.console = console.Console(self.config)
48
 
        self.console.connect('capstonedd.cs.pdx.edu', 9306, 'fec')
 
46
        self.console = console.Console(client_config.ClientConfig())
 
47
        self.console.connect(self.config["host"], self.config["port"],
 
48
                             self.config["database"], self.config["username"],
 
49
                             self.config["password"])
49
50
        
50
51
    def tearDown(self):
51
52
        pass
69
70
        result = self.bash.evaluate('echo $(( 1 + 1 ))')[0]
70
71
        self.assertEqual(result, '2')
71
72
 
72
 
class TestSQL(LingoBaseTester):
 
73
class TestSQL(LingoBaseTester, boots_unit_test.BootsQueryTester):
73
74
    def setUp(self):
74
 
        super(TestSQL, self).setUp()
 
75
        boots_unit_test.BootsQueryTester.setUp(self)
 
76
        LingoBaseTester.setUp(self)
75
77
        self.sql = sql.SQLInterpreter(self.console)
76
78
 
77
79
    def test_plus(self):
78
80
        result = node_graph_values(self.sql.execute('select 1 + 1;'))[0][0][0]
79
81
        self.assertEqual(result, '2')
80
82
 
81
 
class TestLisp(LingoBaseTester):
82
 
    def setUp(self):
83
 
        super(TestLisp, self).setUp()
84
 
        self.lisp = lisp.lisp.LispInterpreter(self.console)
85
 
 
86
 
    def test_plus(self):
87
 
        result = self.lisp.execute('(+ 1 2 3 4)').python_integer()
88
 
        self.assertEqual(result, 10)
89
 
 
90
 
    def test_recursion(self):
91
 
        self.lisp.execute('(setq len (lambda (l) (if l (+ 1 (len (cdr l))) 0)))')
92
 
        result = self.lisp.execute('(len \'(1 2 3 4))').python_integer()
93
 
        self.assertEqual(result, 4)
94
 
        result = self.lisp.execute('(len nil)').python_integer()
95
 
        self.assertEqual(result, 0)
96
 
 
97
83
class TestPipedSQLInterpreter(TestSQL):
98
84
    def setUp(self):
99
85
        super(TestPipedSQLInterpreter, self).setUp()
105
91
        graph = self.sql.execute(piped_sql_query)
106
92
        graph.start()
107
93
        graph.run()
108
 
        self.assertEqual(len(open(temp).readlines()), 1458)
 
94
        self.assertEqual(len(open(temp).readlines()), 1463)
109
95
 
110
96
class TestPythonInterpreter(LingoBaseTester):
111
97
    def setUp(self):
119
105
    def test_len(self):
120
106
        result = self.python.execute('len([1,2,3,4])')
121
107
        self.assertEqual(result, 4)
 
108
 
 
109
try:
 
110
    from boots.lib.lingos.lisp import lisp
 
111
    class TestLisp(LingoBaseTester):
 
112
        def setUp(self):
 
113
            super(TestLisp, self).setUp()
 
114
            self.lisp = lisp.LispInterpreter(self.console)
 
115
    
 
116
        def test_plus(self):
 
117
            result = self.lisp.execute('(+ 1 2 3 4)').python_integer()
 
118
            self.assertEqual(result, 10)
 
119
    
 
120
        def test_recursion(self):
 
121
            self.lisp.execute('(setq len (lambda (l) (if l (+ 1 (len (cdr l))) 0)))')
 
122
            result = self.lisp.execute('(len \'(1 2 3 4))').python_integer()
 
123
            self.assertEqual(result, 4)
 
124
            result = self.lisp.execute('(len nil)').python_integer()
 
125
            self.assertEqual(result, 0)
 
126
except ImportError:
 
127
    pass
 
 
b'\\ No newline at end of file'