A web scraper build to search specific information for a given compound (and its pseudonyms)
1import unittest
2
3from utils.sourceloader import SourceLoader
4
5
6class TestSourceloader(unittest.TestCase):
7 def setUp(self):
8 self.loader = SourceLoader()
9
10 def test_init(self):
11 # Test if sourceloader points to the right directory, where the sources are present.
12 self.assertIn("Source: Source", str(self.loader))
13 self.assertIn("Source: NIST", str(self.loader))
14 self.assertIn("Source: ChemSpider", str(self.loader))
15 self.assertIn("Source: WikipediaParser", str(self.loader))
16
17 def test_include(self):
18 # Tests for the include functionality.
19 self.loader.include(["So.rc.*"])
20
21 self.assertIn("Source: Source", str(self.loader))
22 self.assertNotIn("Source: NIST", str(self.loader))
23 self.assertNotIn("Source: ChemSpider", str(self.loader))
24 self.assertNotIn("Source: WikipediaParser", str(self.loader))
25
26 def test_exclude(self):
27 # Tests for the exclude functionality.
28 self.loader.exclude(["So.rc.*"])
29
30 self.assertNotIn("Source: Source", str(self.loader))
31 self.assertIn("Source: NIST", str(self.loader))
32 self.assertIn("Source: ChemSpider", str(self.loader))
33 self.assertIn("Source: WikipediaParser", str(self.loader))