Esempio n. 1
0
def account_profile():
    global this_u_id
    user_info = user.read_one(this_u_id)
    print("My Account Information:")
    print(user_info)
    print("-" * 40)
    print("                Account Menu")
    print("-" * 40)
    logging.info("Print account_profile menu - Request user response\n")
    if admin == True:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            3 = Show All Accounts
            4 = Main Menu
            5 = Exit
            ''')
    else:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            4 = Main Menu
            5 = Exit
            ''')
    if method == '1':
        logging.info("Response: 1 - Update Account Info\n")
        logging.info("Response 1 request user response\n")
        x = input("user name: ")
        z = getpass.getpass('Password:'******'2':
        logging.info("Response: 2 - Delete My Account\n")
        user.delete(this_u_id)
        this_u_id = 0
        main_menu()
    elif method == '3':
        logging.info("Response: 3 - Show All Accounts\n")
        user.read_all()
        # print(all_users)
        account_profile()
    elif method == '5':
        logging.info("Response: 5 - Exit\n")
        exit()
    else:
        logging.info("Response: 4 - Main Menu\n")
        main_menu()
Esempio n. 2
0
 def test_delete_user(self):
     users = user_api.read_all()
     user = users[randint(0, len(users))]
     try:
         user_api.delete(user.get('user_id'))
     except Exception as e:
         self.assertTrue('Working outside of application context' in str(e))
Esempio n. 3
0
 def test_create_contact_detail(self):
     user = user_api.read_all()[0]
     contact_detail = {
         'email': f'{user.get("username")}@{utils.generate_random_string(6)}.com'
     }
     result, status = contact_detail_api.create(user.get('user_id'), contact_detail)
     self.assertEqual(status, 201)
Esempio n. 4
0
    def test_update_user(self):
        # get existing User
        user = user_api.read_all()[0]

        # update username
        user['username'] = utils.generate_random_string(10)

        # do not update contact details
        del user['contact_details']
        data, status = user_api.update(user.get('user_id'), user)
        self.assertEqual(status, 200)
Esempio n. 5
0
def account_profile():
    global this_u_id
    user_info = user.read_one(this_u_id)
    print("Account Information:")
    print(user_info)
    print("-" * 40)
    print("                Account Menu")
    print("-" * 40)
    if admin == True:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            3 = Show All Accounts
            4 = Main Menu
            5 = Delete Accounts
            6 = Exit
            ''')
    else:
        method = input('''   
            1 = Update My Account Info
            2 = Delete My Account
            4 = Main Menu
            6 = Exit
            ''')
    if method == '1':
        x = input("user name: ")
        z = input("password: "******"email: ")
        user.update(this_u_id, x, z, y)
        account_profile()
    elif method == '2':
        user.delete(this_u_id)
        this_u_id = 0
        main_menu()
    elif method == '3':
        all_users = user.read_all()
        print(all_users)
        account_profile()
    elif method == '5':
        x = input("Enter the ID of the account you want to delete")
        user.delete(x)
        account_profile()
    elif method == '6':
        exit()
    else:
        main_menu()
Esempio n. 6
0
def delete_contact():
    '''
    removes Contacts older than 1 minute
    :return:
    '''
    users = user_api.read_all()
    # normalise datetime
    now = datetime.now() - timedelta(minutes=1)
    now = now.replace(tzinfo=utc)
    for user in users:
        created_on = datetime.strptime(user.get('contact_details')[0].get('created_on'), '%Y-%m-%dT%H:%M:%S.%f%z')
        # normalise datetime
        created_on = created_on.replace(tzinfo=utc)
        if created_on < now:
            try:
                print(f'deleting user: {user.get("name")} {user.get("surname")}')
                user_api.delete(user.get('user_id'))
            except Exception as e:
                assert('Working outside of application context' in str(e))
Esempio n. 7
0
 def test_get_by_id(self):
     user = user_api.read_all()[0]
     user_id = user.get('user_id')
     user = user_api.get_by_id(user_id)
     self.assertEqual(user.get('user_id'), user_id)
Esempio n. 8
0
 def test_read_all(self):
     data = user_api.read_all()
     self.assertTrue(len(data) > 0)