Esempio n. 1
0
 def setUp(self):
     self.authors = Authors()
     # Use betamax to cache responses from scholarometer
     self.recorder = betamax.Betamax(
         self.authors.config.session,
         cassette_library_dir=self.CASSETTE_LIBRARY_DIR
     )
     self.recorder.use_cassette('Authors', record='once')
     self.recorder.start()
Esempio n. 2
0
class AuthorTesting(unittest.TestCase):
    GRAESSER_ID = '1320f77a0cfb40fba374a9fef8d6d72d'
    CASSETTE_LIBRARY_DIR = ".cassettes"

    def setUp(self):
        self.authors = Authors()
        # Use betamax to cache responses from scholarometer
        self.recorder = betamax.Betamax(
            self.authors.config.session,
            cassette_library_dir=self.CASSETTE_LIBRARY_DIR
        )
        self.recorder.use_cassette('Authors', record='once')
        self.recorder.start()

    def tearDown(self):
        self.recorder.stop()

    def test_get_by_id(self):
        self.assertIsNone(self.authors.get_by_id("zzzzzzzzzzzzzzzzzzzzzzzzzz"))

        resp = self.authors.get_by_id(self.GRAESSER_ID)
        self.assertIsNotNone(resp)
        print(resp)

    def test_get_by_name(self):
        resp = self.authors.get_by_name("yyyyyyyyyy")
        self.assertEquals(0, len(resp))

        resp = self.authors.get_by_name("graesser")
        self.assertTrue(len(resp) > 0)

        print(resp)

    def test_get_articles_by_id(self):
        resp = self.authors.get_articles_by_id("zzzzzzzzzzzzzzzzzzzzzzzzzz")
        self.assertEquals(0, len(resp))

        resp = self.authors.get_articles_by_id(self.GRAESSER_ID)
        self.assertTrue(len(resp) > 0)

        print("First item only: " + repr(resp[0]))