0
|
1 __license__ = "MIT"
|
|
2
|
|
3 import unittest
|
|
4 import linkKEGG as lk
|
|
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 return default glycan path example"""
|
|
19 m = lk.linked_entries_from_kegg()
|
|
20 self.assertIn("path", m)
|
|
21 self.assertIn("G00001", m)
|
|
22
|
|
23
|
|
24 def test_bad_db(self):
|
|
25 """"""
|
|
26 import urllib2
|
|
27
|
|
28 with self.assertRaises(urllib2.HTTPError):
|
|
29 m = lk.linked_entries_from_kegg("john", "sally")
|
|
30
|
|
31 def test_bad_dbentry(self):
|
|
32 """"""
|
|
33 import urllib2
|
|
34
|
|
35 with self.assertRaises(urllib2.HTTPError):
|
|
36 m = lk.linked_entries_from_kegg("ko", "map000")
|
|
37
|
|
38 def test_no_links_btn_dbs(self):
|
|
39 """ should return an empty string, cannot write None to file"""
|
|
40 m = lk.linked_entries_from_kegg("br", "gl:G10496")
|
|
41 self.assertEquals(m,"")
|
|
42
|
1
|
43 def test_enzyme_glycan_search_1(self):
|
|
44 """
|
|
45 test "2.4.99.1 ec: " returns
|
|
46 """
|
|
47 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1 ec:")
|
|
48 self.assertIn("2.4.99.1", m)
|
|
49
|
|
50
|
|
51 def test_enzyme_glycan_search_2(self):
|
|
52 """
|
|
53 test "2.4.99.1 ec: 2.4.99.6" returns
|
|
54 """
|
|
55 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1 ec: 2.4.99.6" )
|
|
56 self.assertIn("2.4.99.1", m)
|
|
57 self.assertIn("2.4.99.6", m)
|
|
58
|
|
59 def test_enzyme_glycan_search_3(self):
|
|
60 """
|
|
61 test "2.4.99.1 ec:2.4.99.6" returns
|
|
62 """
|
|
63 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1 ec:2.4.99.6" )
|
|
64 self.assertIn("2.4.99.1", m)
|
|
65 self.assertIn("2.4.99.6", m)
|
|
66
|
|
67 def test_enzyme_glycan_search_4(self):
|
|
68 """
|
|
69 test "2.4.99.1+2.4.99.6" returns. This time '+' is or.
|
|
70 """
|
|
71 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1+2.4.99.6" )
|
|
72 self.assertIn("2.4.99.1", m)
|
|
73 self.assertIn("2.4.99.6", m)
|
|
74
|
|
75 def test_enzyme_glycan_search_4b(self):
|
|
76 """
|
|
77 test "2.4.99.1+ 2.4.99.6" returns. This time '+' is or.
|
|
78 """
|
|
79 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1+ 2.4.99.6" )
|
|
80 self.assertIn("2.4.99.1", m)
|
|
81 self.assertIn("2.4.99.6", m)
|
|
82
|
|
83 def test_enzyme_glycan_search_5(self):
|
|
84 """
|
|
85 test "2.4.99.1 2.4.99.6" returns. Space also means or for the link db.
|
|
86 """
|
|
87 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1 2.4.99.6" )
|
|
88 self.assertIn("2.4.99.1", m)
|
|
89 self.assertIn("2.4.99.6", m)
|
|
90
|
|
91
|
|
92 def test_enzyme_glycan_search_6(self):
|
|
93 """
|
|
94 test "2.4.99.1+nana+2.4.99.6" returns. strangely when inserting junk it still works.
|
|
95 """
|
|
96 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1+nana+2.4.99.6" )
|
|
97 self.assertIn("2.4.99.1", m)
|
|
98 self.assertIn("2.4.99.6", m)
|
|
99
|
|
100 def test_enzyme_glycan_search_6b(self):
|
|
101 """
|
|
102 test "2.4.99.1 nana 2.4.99.6" returns. strangely when inserting junk it still works.
|
|
103 """
|
|
104 m = lk.linked_entries_from_kegg("glycan", "2.4.99.1+nana+2.4.99.6" )
|
|
105 self.assertIn("2.4.99.1", m)
|
|
106 self.assertIn("2.4.99.6", m)
|
|
107
|
|
108 def test_enzyme_glycan_search_7(self):
|
|
109 """
|
|
110 test "\"2.4.99.1\"" is a bad request as it includes quotes.
|
|
111 """
|
|
112 from urllib2 import HTTPError
|
|
113 with self.assertRaises(HTTPError):
|
|
114 m = lk.linked_entries_from_kegg("glycan", "\"2.4.99.1\"" )
|
|
115
|