comparison pyntnclick/tests/test_resources.py @ 562:f22953c43c6d pyntnclick

More resource tests.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 11 Feb 2012 15:17:21 +0200
parents e207dfad0d9e
children 20e296d4a3a5
comparison
equal deleted inserted replaced
561:e207dfad0d9e 562:f22953c43c6d
1 import os.path 1 import os.path
2 from unittest import TestCase 2 from unittest import TestCase
3 3
4 from pyntnclick.resources import Resources 4 from pyntnclick.resources import Resources, ResourceNotFound
5 5
6 6
7 TEST_PATH = os.path.dirname(__file__) 7 TEST_PATH = os.path.dirname(__file__)
8 DATA_PATH = os.path.join(os.path.dirname(TEST_PATH), 'data') 8 DATA_PATH = os.path.join(os.path.dirname(TEST_PATH), 'data')
9 9
20 def test_get_paths_lang(self): 20 def test_get_paths_lang(self):
21 res = Resources('pyntnclick.tests', 'en') 21 res = Resources('pyntnclick.tests', 'en')
22 self.assertEqual([test_path('en/thing'), test_path('thing'), 22 self.assertEqual([test_path('en/thing'), test_path('thing'),
23 data_path('en/thing'), data_path('thing')], 23 data_path('en/thing'), data_path('thing')],
24 res.get_paths('thing')) 24 res.get_paths('thing'))
25
26 def test_get_resource_path_missing(self):
27 res = Resources('pyntnclick.tests')
28 try:
29 res.get_resource_path('should_not_exist')
30 self.fail('Expected ResourceNotFound error.')
31 except ResourceNotFound, e:
32 self.assertEqual('should_not_exist', e.args[0])
33
34 def test_get_resource_path_in_test(self):
35 res = Resources('pyntnclick.tests')
36 self.assertEqual(test_path('test_resources.py'),
37 res.get_resource_path('test_resources.py'))
38
39 def test_get_resource_path_in_data(self):
40 res = Resources('pyntnclick.tests')
41 self.assertEqual(data_path('images/pyntnclick/hand.png'),
42 res.get_resource_path('images/pyntnclick/hand.png'))