class UserTest(unittest.TestCase): def setUp(self): ''' method must be run before each user test ''' self.newuser = User( "Cyprian", "IsItMe?") # Initializing new user object. We will test it def tearDown(self): ''' This method called after each user test ''' User.userlist = [] def test_init(self): ''' Performing first test method to check if user class is initialized correctly ''' self.assertEqual(self.newuser.username, "Cyprian") self.assertEqual(self.newuser.password, "IsItMe?") def test_save_user(self): ''' test method to test if user has been saved into class list ''' self.newuser.save_user() self.assertEqual(len(User.userlist), 1) # Length of list as per lists concept
def setUp(self): ''' method must be run before each user test ''' self.newuser = User( "Cyprian", "IsItMe?") # Initializing new user object. We will test it
def setUp(self): self.Transaction=Transaction(1) self.transactionItem1 = Item('Sky Kraken Beer, 6-pack', 1, 9.99, 2.00,True) self.transactionItem2 = Item('Pepperidge Farm Goldfish Crackers, 16oz', 2, 3.99, .5, False) self.transactionItem3 = Item('Signature 9 Grain Bread, Loaf', 3, 2.99, 1.2, False) self.transactionItem4 = Item('Ben & Jerrys Ice Cream, Pint', 4, 4.59, 1.3, False) self.Transaction.transactionItemList=[self.transactionItem1, self.transactionItem2, self.transactionItem3, self.transactionItem4] self.user=User('101', 'Mike', 'Gilson', '*****@*****.**', '2065551212')
def crawl_influencer_followings(sql, api): for i, influencer_id in enumerate(influencer_id_list): size = len(influencer_id_list) print('------ Influencer {}/{} ------'.format(i + 1, size)) user = User(user_id=influencer_id, sql=sql, api=check_api(current_api=api)) print(user) print() if user.following_count < config.get('max_followings'): user.get_and_save_user_followings() print()
def main(): try: databasemongo = database(DBNAME, DBHOST, DBPORT) numerodoc = recuperodocumenti(databasemongo) elaborodocumenti(databasemongo) utente = User(DOCUMENTLIST, LEXICON, "utente") try: databasemongo.insert(USERCOLLECTION, utente.getjson()) except DuplicateKeyError: print() partenza(numerodoc, utente, databasemongo) except ConnectionFailure: print("Errore di Connessione")
def register(): if request.method == 'GET': return render_template('register.html') if request.form['passwordcheck'] != request.form['password']: return render_template('register.html', error="Passwords did not match") extra_letters = set(request.form['username']) - set( string.ascii_lowercase + string.ascii_uppercase + string.digits) if extra_letters: logger.info("Failed to register user %s" % request.form['username']) return render_template( 'register.html', error="Please make sure username" " contains letters and digits only, no funny business.") user = User.new_user(request.form['username'], request.form['password'], request.form['email']) if user: logger.info("Registered new user %s" % user.username) user.dump() return redirect(url_for('login', welcome=True)) else: return render_template('register.html', error="User already exists")
def load_user(username, password): user = User.from_id(username) if user and user.pw_correct(password): return user else: return None
class TransactionTest(unittest.TestCase): def setUp(self): self.Transaction=Transaction(1) self.transactionItem1 = Item('Sky Kraken Beer, 6-pack', 1, 9.99, 2.00,True) self.transactionItem2 = Item('Pepperidge Farm Goldfish Crackers, 16oz', 2, 3.99, .5, False) self.transactionItem3 = Item('Signature 9 Grain Bread, Loaf', 3, 2.99, 1.2, False) self.transactionItem4 = Item('Ben & Jerrys Ice Cream, Pint', 4, 4.59, 1.3, False) self.Transaction.transactionItemList=[self.transactionItem1, self.transactionItem2, self.transactionItem3, self.transactionItem4] self.user=User('101', 'Mike', 'Gilson', '*****@*****.**', '2065551212') def test_identifyuser(self): self.assertEqual(self.Transaction.identifyUser(self.user), '101') def test_transactionstring(self): self.user.getMemberId() self.assertEquals(self.Transaction.transactionItemList, [self.transactionItem1, self.transactionItem2, self.transactionItem3, self.transactionItem4])
def __init__(self, id="", name="", owner=0, ownername=""): self.coworkers = [] self.items = [] if name and owner and ownername: self.id = id self.name = name self.owner = User(owner, ownername) else: listdetails = getList(id) if listdetails: self.id = listdetails[0] self.name = listdetails[1] self.owner = User(listdetails[2], listdetails[3]) coworkers = getCoworkers(self.id) for coworker in coworkers: self.coworkers.append(User(coworker[1], coworker[2])) items = getItems(self.id) for item in items: self.items.append(Item(item[0], item[2], item[3])) else: raise KeyError(_("notexisting"))
def login(): if request.method == 'GET': return render_template('login.html') email = request.form['email'] password = request.form['password'] user = User.get(uid=email) if user != None and user.check_authenticated(password=password): login_user(user) return redirect('/') return 'Bad login'
def main_handler(): newuser = User.from_handle(USERNAME) # New User Data if os.path.isfile(USER_DATA): userdata = load_user_data(newuser) # Old user data else: userdata = json.loads(User(USERNAME).toJSON()) # get followers notification old_followers = userdata['followers'] notifications = newuser.get_notifications(old_followers) # get repo notifications newrepos = newuser.repos oldrepos = userdata['repos'] for newrepo in newrepos: if oldrepos is None: oldstars, oldwatchers, oldforks = 0, 0, 0 else: for oldrepo in oldrepos: if newrepo.name == oldrepo['name']: oldstars, oldwatchers, oldforks = oldrepo[ 'stars'], oldrepo['watchers'], oldrepo['forks'] break else: oldstars, oldwatchers, oldforks = 0, 0, 0 repo_notifications = newrepo.get_notifications(oldstars, oldwatchers, oldforks) # print("Repo: " + str(newrepo)) notifications += repo_notifications for notification in notifications: #print(notification.message) notification.notify() dump_user_data(newuser)
from userclass import User from systemclass import System system = System("Synthesa") user = User("kotobaza", system=system) while True: string = input().lower() if string == "stop": break eval(string)
def create_useraccount(user_name, password): """ Creates a new user account. """ new_user = User(user_name, password) return new_user
def load_user(id): return User.from_id(id)
def user_loader(email): print('in user_loader') return User.get(uid=email)
def create_user(account_owner, account_key): # function to create a new user new_user = User(account_owner, account_key) return new_user
def setUp(self): self.user=User('101', 'Mike', 'Gilson', '*****@*****.**', '2065551212')
def __str__(self): return User.getMemberId(), self.transactionItemList
def identifyUser(self, User): return User.getMemberId()
def addCoworker(self, coworker, coname, msgid): self.coworkers.append(User(coworker, coname)) dbfunc = Thread(target=insertCoworker, args=(self.id, coworker, coname, msgid)) dbfunc.start()
def display_user(): return User.display_user()