diff 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
line wrap: on
line diff
--- a/pyntnclick/tests/test_resources.py	Sat Feb 11 15:05:34 2012 +0200
+++ b/pyntnclick/tests/test_resources.py	Sat Feb 11 15:17:21 2012 +0200
@@ -1,7 +1,7 @@
 import os.path
 from unittest import TestCase
 
-from pyntnclick.resources import Resources
+from pyntnclick.resources import Resources, ResourceNotFound
 
 
 TEST_PATH = os.path.dirname(__file__)
@@ -22,3 +22,21 @@
         self.assertEqual([test_path('en/thing'), test_path('thing'),
                           data_path('en/thing'), data_path('thing')],
                          res.get_paths('thing'))
+
+    def test_get_resource_path_missing(self):
+        res = Resources('pyntnclick.tests')
+        try:
+            res.get_resource_path('should_not_exist')
+            self.fail('Expected ResourceNotFound error.')
+        except ResourceNotFound, e:
+            self.assertEqual('should_not_exist', e.args[0])
+
+    def test_get_resource_path_in_test(self):
+        res = Resources('pyntnclick.tests')
+        self.assertEqual(test_path('test_resources.py'),
+                         res.get_resource_path('test_resources.py'))
+
+    def test_get_resource_path_in_data(self):
+        res = Resources('pyntnclick.tests')
+        self.assertEqual(data_path('images/pyntnclick/hand.png'),
+                         res.get_resource_path('images/pyntnclick/hand.png'))