def post(st): n = random.randint(0, 2) if st is 0: t = tags1(n) rt = str((wikiquotes.quote_of_the_day("english")[0])) #print(rt+t) return (rt + t) else: t = tags2(n) cn = ChuckNorris() data = str(cn.random()) while len(data) > 270: data = cn.random() #print(data+t) return (data + t)
class ChuckNorrisTestCase(unittest.TestCase): def setUp(self): self.cn = ChuckNorris() def test_retrieve_jokes_random(self): data = self.cn.random() self.assertIsNotNone(data) self.assertIsNotNone(data.id) self.assertIsNotNone(data.joke) self.assertIsNotNone(data.categories) self.assertTrue(isinstance(data.categories, list)) def test_retrieve_jokes_by_id(self): data = self.cn.get_jokes_by_id(15) self.assertIsNotNone(data) self.assertIsNotNone(data.id) self.assertIsNotNone(data.joke) self.assertIsNotNone(data.categories) self.assertTrue(isinstance(data.categories, list)) self.assertEqual(data.id, 15) self.assertEqual(data.joke, 'When Chuck Norris goes to donate blood, he declines the syringe, and instead requests a hand gun and a bucket.') def test_retrieve_jokes_categories(self): data = self.cn.get_jokes_categories() self.assertTrue(isinstance(data, list)) def test_retrieve_jokes_count(self): data = self.cn.get_jokes_count() self.assertTrue(isinstance(data, int)) def test_retrieve_jokes_random_3_records(self): data = self.cn.random(total=3) self.assertTrue(isinstance(data, list)) self.assertEqual(len(data), 3) for i in data: self.assertIsNotNone(i) self.assertIsNotNone(i.id) self.assertIsNotNone(i.joke) self.assertIsNotNone(i.categories) def test_retrieve_jokes_random_limit_category(self): data = self.cn.random(categories=['nerdy']) self.assertIsNotNone(data) self.assertIsNotNone(data.id) self.assertIsNotNone(data.joke) self.assertIsNotNone(data.categories) self.assertEqual(data.categories[0], 'nerdy')
# -*- coding: utf-8 -*- import string import random from chuck import ChuckNorris jokes = ChuckNorris() def fiveLines(): print "\n" * 4 def cleanScreen(): print "\n" * 24 def deleteLowercase(p): return string.upper(p) def isRightLetter(c): if c in "abcdefghijqlmnñopqrstuvwxyz": if c not in "aeiou": return True else: return False else: return False def countWords(p):
#gia na treksei to programma prepei na ektelestei sto cmd #h entolh "python -m pip install chuck-norris-python" from chuck import ChuckNorris cn = ChuckNorris() data = cn.random() print(data.joke) joke = data.joke spl = joke.split() for word in spl: if (len(word) > 2): print((ord(word[0]) + ord(word[-1])) % 3) else: print(-1)
from tkinter import font from Config import Config # Methods def random_joke(): data = cn.random() text_var.set(data.joke) # Create the config config = Config() # Create the API object for Chuck Norris cn = ChuckNorris() # Create our window and apply settings root = tk.Tk() root.title(config.TITLE) root.geometry(f'{config.WIDTH}x{config.HEIGHT}') root.resizable(False, False) # Fonts font_n = font.Font(family=config.FONT_FAMILY, size=config.FONT_SIZE) # Window layout frame = tk.Frame(root, bg=config.FRAME_COLOR) frame.pack(fill='both', expand=True) joke_frame = tk.Frame(frame, bg=config.JOKE_BACKGROUND_COLOR)
def setUp(self): self.cn = ChuckNorris()