def get_net_worth(): # expecting query arguments "/api/[email protected]" email = request.args.get("email") store = InMemoryDataStore() u = store.get_user( email) # will raise an error if not found resulting in a 500 return jsonify(u.net_worth)
def test_datastore_get_user_returns_the_right_values(self): users_file = os.path.join(self.TEST_STORAGE_PATH, "users.pck") # check for no user in database with self.assertRaises(ValueError): store = InMemoryDataStore() store.get_user(self.TEST_USER.email) # check the right user is returned store = InMemoryDataStore(users_file) u = store.get_user(self.TEST_USER.email) self.assertEqual(u.first_name, self.TEST_USER.first_name) self.assertEqual(u.last_name, self.TEST_USER.last_name) self.assertEqual(u.age, self.TEST_USER.age) # check that editing the user doesn't change the database user u.first_name = "YuGiOh" self.assertEqual(InMemoryDataStore._USERS[0].first_name, self.TEST_USER.first_name)