Exemple #1
0
def Get_quotes(author, numPosts):
    obj = GoodRead()
    obj.set_base_url("https://www.goodreads.com/")
    print("---------Top " + str(numPosts) + " Quotes of " + author +
          "---------")
    print("-------------------------------------------------")
    print('')
    try:
        #if obj.check_author_type(author):
        #    raise ValueError("Author name should only contain alphabetic characters!")
        if all(x.isdigit() for x in str(author)):
            obj.exitcondition = True
            raise ValueError(
                "Author name should only contain alphabetic characters!")
        obj.set_author_query(str(author))
        if not all(x.isdigit() for x in str(numPosts)):
            obj.exitcondition = True
            raise ValueError("Number of Posts should be an Integer >0")
        if not obj.exitcondition:
            obj.set_numQuotes(int(numPosts))
        if not obj.exitcondition:
            obj.set_query_url()
        if not obj.exitcondition:
            obj.set_quotesquery_name()
        if not obj.exitcondition:
            obj.get_top_quotes(obj.author_query, obj.numQuotes, obj.query_url,
                               obj.filename)

        return obj.filename
    except ValueError as e:
        print(e)
Exemple #2
0
 def test_blank_link_get_quotes(self):
     obj = GoodRead()
     self.assertRaises(
         obj.get_top_quotes("Mark XYZ", 0, "",
                            "abc.json"))
Exemple #3
0
def Authenticate(email,password):
    obj = GoodRead()
    obj.set_base_url("https://www.goodreads.com/")
    obj.set_email(email)
    obj.set_password(password)
    obj.set_credential()
Exemple #4
0
 def test_wrong_link_get_quotes(self):
     obj = GoodRead()
     self.assertRaises(
         obj.get_top_quotes("Mark XYZ", 0, "https://www.xxxxxxxxxxxs.com/quotes/search?&q=mark+twain&commit=Search",
                            "abc.json"))
Exemple #5
0
 def test_email(self):
     obj = GoodRead()
     self.assertEqual(obj.set_email("*****@*****.**"), "*****@*****.**")
Exemple #6
0
 def test_invalid_numpostalpha(self):
     obj = GoodRead()
     self.assertRaises(obj.set_numQuotes('a'))
Exemple #7
0
 def test_invalid_numpostNegativeInt(self):
     obj = GoodRead()
     self.assertRaises(obj.set_numQuotes(-10))
Exemple #8
0
 def test_random_author_get_quotes(self):
     obj = GoodRead()
     self.assertRaises(obj.get_top_quotes("Mark XYZ", 0,"https://www.goodreads.com/quotes/search?&q=mark+twain&commit=Search","abc.json"))
Exemple #9
0
 def test_invalid_authorNegativeInt(self):
     obj = GoodRead()
     self.assertRaises(obj.set_author_query(-1))
Exemple #10
0
 def test_blank_author_get_quotes(self):
     obj = GoodRead()
     obj.query_url = "https://www.goodreads.com/quotes/search?&q=mark+twain&commit=Search"
     self.assertRaises(obj.get_top_quotes("", 8,obj.query_url,"abc.json"))
Exemple #11
0
 def test_wrong_password(self):
     obj = GoodRead()
     obj.set_email("*****@*****.**")
     obj.set_password("abc")
     obj.set_base_url("https://www.goodreads.com/")
     self.assertEqual(obj.authenticate(obj.email, obj.password, obj.sign_in_url, obj.redirect_url), False)
Exemple #12
0
 def test_empty_email(self):
     obj = GoodRead()
     self.assertRaises(obj.set_email(""))
Exemple #13
0
 def test_empty_password(self):
     obj = GoodRead()
     self.assertRaises(obj.set_password(""))
Exemple #14
0
 def test_password(self):
     obj = GoodRead()
     self.assertEqual(obj.set_password("rupam.K@19"), "rupam.K@19")