Пример #1
0
 def test_author_quote(self, mock_get):
     author_quote_response = {
         "count":
         2,
         "results": [{
             "_id": "5d91b45d9980192a317c87f3",
             "quoteText":
             "Doing nothing is better than being busy doing nothing.",
             "quoteAuthor": "Lao Tzu"
         }, {
             "_id": "5d91b45d9980192a317c87ed",
             "quoteText": "To lead people walk behind them.",
             "quoteAuthor": "Lao Tzu"
         }]
     }
     name = "Lao Tzu"
     mock_get.return_value = Mock(ok=True)
     mock_get.return_value.json.return_value = author_quote_response
     expected = [
         "Doing nothing is better than being busy doing nothing.",
         "To lead people walk behind them."
     ]
     author_quote_result_count, author_quote_result = Quotes.get_quote_by_author(
         name)
     self.assertEqual(author_quote_result, expected)
Пример #2
0
 def test_author_not_found_zero_quote(self, mock_get):
     all_quote_response = {"count": 0, "results": []}
     name = "Lao "
     mock_get.return_value = Mock(ok=True)
     mock_get.return_value.json.return_value = all_quote_response
     expected = []
     author_quote_result_count, author_quote_result = Quotes.get_quote_by_author(
         name)
     self.assertEqual(author_quote_result, expected)
Пример #3
0
def get_quote(type):
    if type == 1:
        quotes, author = Quotes.get_random()
        print(quotes)
    if type == 2:
        name = input("enter authore name")
        count, quotes = Quotes.get_quote_by_author(name)
        for i in range(count):
            print(quotes[i])
    if type == 3:
        count, quotes, author = Quotes.get_all_quote()
        for i in range(count):
            print(quotes[i])