summaryrefslogtreecommitdiff
path: root/tests/tests.py
blob: 136b8ea8f79802f46da39ed21721ce20fc5cabe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
#tests.py - test codebase

import unittest
import pyscholar

class TestResolver(unittest.TestCase):
    def test_pyscholar_resolver(self):
        '''test pyscholar.resolve()'''
        #pyscholar.resolve(some_search_result) should go grab the pdf and metadata for a result object
        pass

class TestGoogleScholar(unittest.TestCase):
    def test_google_search(self):
        '''test pyscholar.packages.GoogleScholar'''
        google_scholar = pyscholar.packages.GoogleScholar(lang=en)
        results = google_scholar.query("PDMS", count=100)

        #there must be at least one result for that query
        self.assertTrue(len(results)>0)
        #in fact, we might as well demand there's 100 results
        self.assertTrue(len(results)==100)

        #not sure what else to test

        return
    def test_google_search_proxy(self):
        #TODO: test pyscholar.packages.GoogleScholar() with ezproxy proxy
        pass
 
class TestScienceDirect(unittest.TestCase):
    def test_sciencedirect_search(self):
        num_results = 50
        
        sciencedirect = pyscholar.packages.ScienceDirect()
        results = sciencedirect.query("PDMS", count=num_results)

        #there must be at least one result for that query
        self.assertTrue(len(results)>0)
        #in fact, we might as well demand there's num_results results
        self.assertTrue(len(results)==num_results)
        
        #test values
        for result in results:
            real_result = pyscholar.resolve(result)
            #check that the values in 'result' match those in 'real_result' (the article page scrape)
        return
    def test_sciencedirect_article(self):
        sciencedirect = pyscholar.packages.ScienceDirect()
        article = sciencedirect.fetch("some article name here")
        #do what now?
        pass

if __name__ == '__main__':
    unittest.main()