Added fit.ActionFixture and fixed the loader. Added ListAdapter.
[stuff.git] / pyfit / test_util.py
blob358a547a300e1a7a08e254053bbf087d89730a3d
1 import unittest
2 from util import *
3 from plaintypes import *
5 class TestUtil(unittest.TestCase):
6 def setUp(self):
7 self.adapters = DefaultAdapters()
9 def test_if_apply_throws_when_function_returns_None(self):
11 class FakeFixture(object):
12 def func(self):
13 pass
15 operation = MethodCall('func')
16 fixture = FakeFixture()
17 cell = Cell('dummy')
18 try:
19 operation.apply(fixture, cell, self.adapters)
20 except Exception, inst:
21 pass
22 self.assertEqual(str(inst), 'returned None')
24 def test_bool_adapter_1(self):
26 class FakeFixture(object):
27 def func(self):
28 return False
30 operation = MethodCall('func')
31 fixture = FakeFixture()
32 cell = Cell('false')
34 operation.apply(fixture, cell, self.adapters)
35 self.assertEqual(cell.has_passed, True)
37 def test_bool_adapter_2(self):
38 class FakeFixture(object):
39 reliable = False
41 operation = SetAttribute('reliable')
42 fixture = FakeFixture()
43 cell = Cell('false')
44 operation.apply(fixture, cell, self.adapters)
45 self.assertEqual(fixture.reliable, False)
47 def test_list_adapter(self):
48 class FakeFixture(object):
49 phones = []
51 operation = SetAttribute('phones')
52 fixture = FakeFixture()
53 cell = Cell('(209)373 7453, (209)373 7454')
54 operation.apply(fixture, cell, self.adapters)
55 self.assertEqual(fixture.phones, ['(209)373 7453', '(209)373 7454'])