def __init__(self, app_name=None, unique=False, **kwargs): super(FacebookTestUser, self).__init__(**kwargs) self.app_name = app_name self.unique = unique self.graph = get_static_graph(self.app_name) self.testusers = TestUsers(self.graph) self.users = [] self.index = 0
def handle(self, *args, **options): installed = options.get('installed') apps = [] if args: for arg in args: try: application = settings.FACEBOOK_APPS[arg] apps.append(application) except KeyError: raise CommandError('Application %s does not exist' % arg) else: apps.append(settings.FACEBOOK_APPS.values()[0]) for app in apps: graph = get_static_graph(app_dict=app) testusers = TestUsers(graph) user = testusers.generate_new_test_user(installed=installed) self.stdout.write(u'Generated new Testuser: %s\n' % user)
def handle(self, *args, **options): apps = [] update = options.get('update') # Not implemented yet. Always update. if args: for arg in args: try: application = settings.FACEBOOK_APPS[arg] apps.append(application) except KeyError: raise CommandError('Application %s does not exist' %arg ) else: apps.append(settings.FACEBOOK_APPS.values()[0]) for app in apps: graph = get_static_graph(app_dict=app) testusers = TestUsers(graph) users = testusers.get_test_users() self.stdout.write(u' Testusers: %s\n' % users) for user in users: installed = '*' if getattr(user, 'access_token', False) else '' self.stdout.write(u'%s\t%s %s\n' % (user.id, user.login_url, installed))
def handle(self, *args, **options): if args: try: arg1 = int(args[0]) except AttributeError: raise CommandError('Arg %s must be integer' % user1) try: arg2 = int(args[1]) except IndexError: arg2 = None except AttributeError: raise CommandError( 'Arg %s must be integer or empty for all users.' % user2) try: app = args[2] except IndexError: app = None else: raise CommandError('Need at least one user_id.') graph = get_static_graph(app_dict=app) testusers = TestUsers(graph) try: user1 = TestUser.objects.get(id=arg1) except TestUser.DoesNotExist: raise CommandError('User1 does not exist.') if arg2: try: user2 = TestUser.objects.get(id=arg2) except TestUser.DoesNotExist: raise CommandError('User2 does not exist.') response = testusers.make_friends_with(user1, user2) self.stdout.write(u' %s\n' % response) else: users = TestUser.objects.exclude(id=user1.id) for user in users: response = testusers.make_friends_with(user1, user) self.stdout.write(u' %s\n' % response)