setup.py: Try git when printing the release version
[git-cola.git] / test / test_cola_model.py
blob5f0ab43377342fe52876c97651406c643a6dfa7e
1 #!/usr/bin/env python
2 import unittest
3 import helper
5 from cola.models.base import BaseModel
7 class ExampleModel(BaseModel):
8 """An example model for use by these tests"""
9 def pass_through(self, value):
10 """Passes values through unmodified"""
11 return value
13 class ModelTest(unittest.TestCase):
14 """Tests the cola.model.Model class"""
16 def test_create_attribute(self):
17 """Test that arbitrary attributes provide set_* methods"""
18 model = ExampleModel()
19 model.set_foo('bar')
20 self.assertEqual(model.foo, 'bar')
22 def test_param(self):
23 """Test attribute access in case we f*** up __getattr__"""
24 model = ExampleModel()
25 model.attribute = 'value'
26 self.assertEqual(model.param('attribute'), 'value')
28 # basic tests to ensure __getattr__ is sane
29 def test_method(self):
30 """Test calling a concrete method"""
31 model = ExampleModel()
32 self.assertEqual(model.pass_through('value'), 'value')
34 def test_dict_attribute(self):
35 """Test setting dictionaries/dictionary values."""
36 model = ExampleModel()
37 model.thedict = { 'hello': 'world' }
38 self.assertEqual(model.thedict['hello'], 'world' )
41 if __name__ == '__main__':
42 unittest.main()