def cleanup(self): columns = utils.get_var_details() #Steps to delete a var created from var collection var_name = columns['var_business_name'][0] var_name = var_name.strip() db.delete_var(var_name) #Steps to delete var user created from user collection var_email = columns['email'][0] var_email = var_email.strip() db.delete_user(var_email) #Steps to delete a customer created from customer collection cust_name = columns['var_business_name'][1] cust_name = cust_name.strip() db.delete_customer(cust_name) #Steps to delete customer user created from user collection cust_email = columns['email'][1] cust_email = cust_email.strip() db.delete_user(cust_email) #Steps to delete a config created config_name = columns['var_business_name'][2] config_name = config_name.strip() db.delete_config(config_name) #Steps to delete a location created loc_name = columns['var_business_name'][2] loc_name = loc_name.strip() db.delete_location(loc_name)
def test_delete_user(self): with db.connect() as connection: user = User(id=get_random_id(connection), first_name="Augustus", is_bot=False) db.add_user(connection, user, datetime.utcnow()) db.delete_user(connection, user.id) result = db.lookup_user(connection, user.id) self.assertFalse(result)
def test_update_user(self): with db.connect() as connection: uid = get_random_id(connection) user = User(id=uid, first_name="Augustus", is_bot=False) db.add_user(connection, user, datetime.utcnow()) updated_user = User(id=uid, first_name="Filamentis", is_bot=False) db.update_user(connection, updated_user, user.id) result = db.lookup_user(connection, user.id) self.assertEqual(result.id, updated_user.id) self.assertEqual(result.first_name, updated_user.first_name) db.delete_user(connection, user.id)
def test_add_user(self): with db.connect() as connection: timestamp = datetime.now() user = User( id=get_random_id(connection), first_name="Augustus", is_bot=False, joined_on=timestamp, ) db.add_user(connection, user, timestamp) result = db.lookup_user(connection, user.id) self.assertTrue(result) self.assertEqual(result.id, user.id) self.assertEqual(result.first_name, user.first_name) self.assertEqual(result.joined_on.ctime(), timestamp.ctime()) db.delete_user(connection, user.id)
def delete(username=None): if username: db.delete_user(username) flash(messages.USER_DELETED, 'success') return redirect(url_for('admin.index'))