0
|
1 __license__ = "MIT"
|
|
2
|
|
3 import unittest
|
|
4 import findKEGG as fk
|
|
5
|
|
6
|
|
7 class SimpleUnitTest(unittest.TestCase):
|
|
8 def setUp(self):
|
|
9 import os
|
|
10
|
|
11 os.environ["http_proxy"] = "" # work around for IOError: [Errno url error] invalid proxy for http:
|
|
12 pass
|
|
13
|
|
14 def tearDown(self):
|
|
15 pass
|
|
16
|
|
17 def test_no_db_specified(self):
|
|
18 """should raise error"""
|
|
19 with self.assertRaises(IOError):
|
|
20 m = fk.find_entries_in_KEGG([], " ")
|
|
21 with self.assertRaises(IOError):
|
|
22 m = fk.find_entries_in_KEGG("", " ")
|
|
23 with self.assertRaises(IOError):
|
|
24 m = fk.find_entries_in_KEGG(None, " ")
|
|
25
|
|
26 def test_no_query_specified(self):
|
|
27 """should raise error"""
|
|
28 with self.assertRaises(IOError):
|
|
29 m = fk.find_entries_in_KEGG("glycan", "")
|
|
30 with self.assertRaises(IOError):
|
|
31 m = fk.find_entries_in_KEGG("glycan", [])
|
|
32 with self.assertRaises(IOError):
|
|
33 m = fk.find_entries_in_KEGG("glycan", None)
|
|
34
|
|
35
|
|
36 def test_bad_db(self):
|
|
37 """should raise error"""
|
|
38 import urllib2
|
|
39
|
|
40 with self.assertRaises(urllib2.HTTPError):
|
|
41 m = fk.find_entries_in_KEGG("john", "glucose")
|
|
42
|
|
43 def test_unfindable_entry(self):
|
|
44 """should return None"""
|
|
45 m = fk.find_entries_in_KEGG("glycan", "sally")
|
|
46 self.assertIsNone(m)
|
|
47
|
|
48 def test_find_example(self):
|
|
49 m = fk.find_entries_in_KEGG("glycan", "glucose")
|
|
50 self.assertIsNotNone(m)
|
|
51 self.assertIn("GDP-glucose", m)
|
|
52
|
|
53 def test_query_has_newlines(self):
|
|
54 """
|
|
55 should be fine and return entries
|
|
56 """
|
|
57 m = fk.find_entries_in_KEGG("glycan", "glucose\n UDP")
|
|
58 self.assertIsNotNone(m)
|
|
59 self.assertIn("UDP-D-glucose", m)
|
|
60
|