My first app! A simple Twitter bot


#1

It’s a simple Twitter bot that stores and tweets quotes I like.

I used Flask and MySQL

First of all I want to thank Zed! Without your book: “Learn Python the Hard Way” I would have not started this journey through programming. Thx!

You can find the code, links, installation on Github

If you want to test the app fully you can tweet from my own Twitter account by registering to the site with this Register Key: 123456

Two questions:

  1. Do you think it is possible to run this test without making a real tweet?
def test_twitter(self):
    rv = self.register('Admin', 'Admin', 'Admin', secret_code.register_key)
    rv = self.login('Admin', 'Admin')
    rv = self.app.get('/twitter', content_type='html/text')
  1. Do you think it is possible to run a test that checks if clicking the “Home” button on the navbar the browser actually goes to the homepage? I know it’s a silly test but it is the first test that came up to my mind :slight_smile:

Thx!

Stefano


#2

cool man, unfortunately I hate twitter and facebook. Look up a guy name Siraj on youtube, he does that sort of thing. :space_invader:

by the way Zed Shaw wrote twitter so download his books and learn.

Peace man


#3

Noice! That’s actually a pretty tough app to write. How long did it take you?


#4

Yes, you will want to use this module:

https://docs.python.org/3/library/unittest.mock.html

You can use that to “fake” out the actual APIs that post the tweet and return some bogus data.


#5

Thanks Zed for your reply!

It took me all my spare time (nights and weekends) for about 3 months!

I didn’t build it from scratch. I basically merged two tutorials I found on the internet.

I got stuck so many times! But I didn’t give up!

It helped me one of your advice: “If you find yourself staring at the code, you need to expand your knowledge and learn more”

Thanks again

Stefano