def test_MarketProfile_replace_social_no_proof(self): p = Profile(self.db) p.add_social_account("FACEBOOK", "test_updated_username") u = p.get() self.assertEqual(1, len(u.social)) self.assertEqual(0, u.social[0].type) self.assertEqual('test_updated_username', u.social[0].username)
def test_MarketProfile_add_social_invalid(self): p = Profile(self.db) p.add_social_account("TEST", "test_twitter_username") u = p.get() self.assertEqual(1, len(u.social)) self.assertEqual(0, u.social[0].type) self.assertEqual('test_fb_username', u.social[0].username)
def test_MarketProfile_add_social_no_proof(self): p = Profile(self.db) p.add_social_account("TWITTER", "test_twitter_username") u = p.get() self.assertEqual(2, len(u.social)) self.assertEqual(0, u.social[0].type) self.assertEqual('test_fb_username', u.social[0].username) self.assertEqual(1, u.social[1].type) self.assertEqual('test_twitter_username', u.social[1].username)
def addsocialaccount(): parser = argparse.ArgumentParser( description="Add a social media account to the profile.", usage='''usage: networkcli.py addsocialaccout -t TYPE, -u USERNAME, -p PROOF''') parser.add_argument('-t', '--type', help="the type of account") parser.add_argument('-u', '--username', help="the username") parser.add_argument('-p', '--proof', help="the proof url") args = parser.parse_args(sys.argv[2:]) p = Profile() p.add_social_account(args.type, args.username, args.proof)
def add_social_account(self, request): try: p = Profile(self.db) if "account_type" in request.args and "username" in request.args and "proof" in request.args: p.add_social_account(request.args["account_type"][0], request.args["username"][0], request.args["proof"][0]) request.write(json.dumps({"success": True})) request.finish() return server.NOT_DONE_YET except Exception, e: request.write(json.dumps({"success": False, "reason": e.message}, indent=4)) request.finish() return server.NOT_DONE_YET
def add_social_account(self, request): p = Profile() if "account_type" in request.args and "username" in request.args and "proof" in request.args: p.add_social_account(request.args["account_type"][0], request.args["username"][0], request.args["proof"][0])