def test_set_user_stats(self): c = Controller(username='******') c.set_user_stats(likes=4, comments=3, followed=2, unfollowed=1) self.assertEqual(c.user.likes, 4) self.assertEqual(c.user.commented, 3) self.assertEqual(c.user.followed, 2) self.assertEqual(c.user.unfollowed, 1)
def test_set_users_followed(self): followed = [ FollowedUser('juan', datetime.datetime.now()), FollowedUser('miguel', datetime.datetime.now()), FollowedUser('arturo', datetime.datetime.now()) ] c = Controller(username='******') c.set_users_followed(followed) total_followed = c.user.follower_set.select().count() self.assertEqual(total_followed, 3)
def test_set_users_unfollowed(self): c = Controller(username='******') unfollowed = [ FollowedUser('user1', None), FollowedUser('user2', None), FollowedUser('user3', None) ] c.set_users_unfollowed(unfollowed) not_follows = c.user.follower_set.select( Follower.following == False) # noqa self.assertEqual(not_follows.count(), 0)
def main(): parser = get_parser() args = parser.parse_args() if args.config is not None: load_config(filepath=args.config) scrapper = InstaScrapper(hide_browser=args.hide_browser) bot = InstaBot(scrapper, username=args.username, password=args.password) c = Controller(username=args.username) signal.signal(signal.SIGINT, partial(signal_handler, bot, c)) c.run(bot)
def test_get_users_to_unfollow(self): c = Controller(username='******') yesterday = datetime.datetime.now() - datetime.timedelta(days=1) Follower.create(user=c.user, username='******', unfollow_date=yesterday) Follower.create(user=c.user, username='******', following=False, unfollow_date=yesterday) users = c.get_users_to_unfollow() self.assertEqual(users.count(), 1)
def test_set_stats(self): c = Controller(username='******') c.set_stats(self.bot) self.assertEqual(c.user.likes, self.bot.likes_given_by_bot)
def test_get_users_following(self): c = Controller(username='******') following = c.get_users_following() self.assertEqual(len(following), 3)
def test_controller_exists_user(self): c = Controller(username='******') self.assertEqual(c.user.username, 'darude') self.assertFalse(c.is_new)
def test_controller_create_user(self): c = Controller(username='******') self.assertEqual(c.user.username, 'pepe') self.assertTrue(c.is_new)