-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.py
54 lines (41 loc) · 1.76 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from unittest import TestCase
from oml import RunTime
class InitialTest(TestCase):
def setUp(self):
self.dataset = [
{"nome": "Thiago Avelino", "field1": 10, "field2": 20,
"address": "Av. Castelo Branco, 1300, Cacapava, SP, Brasil"},
{"nome": "Luiz Vital", "field1": 30, "field2": 40,
"address": "Cacapava, SP, Brasil"},
{"nome": "Carlos Leite", "field1": 50, "field2": 60,
"address": "Sao Jose dos Campos, SP, Brasil"}
]
def test_multi_ROW(self):
OML = """ROW('new_collum1', OML.SUM({@field1, @field2}))
ROW('new_collum2', OML.SUB({@field1, @field2}))
ROW('geo', OML.GEO_LOCATION("@address"))
ROW('func', function() return 'abc' end)
{dict1=@field1*@field2, dict2=123}"""
run = RunTime("lua", self.dataset, OML)
self.assertTrue(run)
self.assertEqual(len(run), 3)
def test_set_CLASS(self):
OML = """ROW('new_collum1', TEST.SUM({@field1, @field2}))
ROW('new_collum2', TEST.SUB({@field1, @field2}))
ROW('geo', TEST.GEO_LOCATION("@address"))"""
run = RunTime("lua", self.dataset, OML, {"TEST": "oml.base.OMLBase"})
self.assertTrue(run)
self.assertEqual(len(run), 3)
def test_set_two_CLASS(self):
OML = """ROW('new_collum1', TEST.SUM({@field1, @field2}))
ROW('new_collum2', TEST.SUB({@field1, @field2}))
ROW('geo', OML.GEO_LOCATION("@address"))"""
run = RunTime("lua", self.dataset, OML,
{"TEST": "oml.base.OMLBase", "OML": "oml.base.OMLBase"})
self.assertTrue(run)
self.assertEqual(len(run), 3)
if __name__ == '__main__':
unittest.main()