def test_leave_group_user_post(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testLeaveGroupUserGroup") person.delete_user("testLeaveGroupUser") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testLeaveGroupUser' session['group_name'] = 'testLeaveGroupUserGroup' group_member = Person("testLeaveGroupUser", "testLeaveGroupUser", "*****@*****.**", "testLeaveGroupUser") group_member_2 = Person("testLeaveGroupUser2", "testLeaveGroupUser2", "*****@*****.**", "testLeaveGroupUser2") response = client.post('/create_group', data=dict(group_name="testLeaveGroupUserGroup", selected_members=['testLeaveGroupUser2']), follow_redirects=True) self.assertEqual(["testLeaveGroupUser", "testLeaveGroupUser2"], group.get_all_users_in_group("testLeaveGroupUserGroup")) response = client.post('/leave_group_user', follow_redirects=True) self.assertIn(b'<h5 class="text-right" id="brand">testLeaveGroupUser</h5>', response.data) self.assertEqual(["testLeaveGroupUser2"], group.get_all_users_in_group("testLeaveGroupUserGroup")) group.delete_group("testLeaveGroupUserGroup") person.delete_user("testLeaveGroupUser") person.delete_user("testLeaveGroupUser2") person.remove_email_from_auth("*****@*****.**", "password")
def test_add_group_picture(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testAddGroupPictureGroup") person.delete_user("testAddGroupPicture") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testAddGroupPicture' session['group_name'] = 'testAddGroupPictureGroup' group_member = Person("testAddGroupPicture", "testAddGroupPicture", "*****@*****.**", "testAddGroupPicture") group_member_2 = Person("testAddGroupPicture2", "testAddGroupPicture2", "*****@*****.**", "testAddGroupPicture2") response = client.post('/create_group', data=dict(group_name="testAddGroupPictureGroup", selected_members=['testAddGroupPicture2']), follow_redirects=True) response = client.post("/add_group_picture", data=dict(image=(io.BytesIO(b"test bytes"), 'test.jpg')), follow_redirects=True) self.assertIn(b'testAddGroupPictureGroup_group_picture.JPG', response.data) group.delete_group("testAddGroupPictureGroup") person.delete_user("testAddProfilePicture") person.delete_user("testAddProfilePicture2") person.remove_email_from_auth("*****@*****.**", "password") person.remove_email_from_auth("*****@*****.**", "password")
def test_add_purchase_post_splits_not_100(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testAddPurchasePost") person.delete_user("testAddPurchasePostMember") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'test1' session['group_name'] = 'testAddPurchasePost' group_member = Person("testAddPurchasePostMember", "testAddPurchasePostMember", "*****@*****.**", "testAddPurchasePostMember") response = client.post('/create_group', data=dict(group_name="testAddPurchasePost", selected_members=['testAddPurchasePostMember']), follow_redirects=True) response = client.post('/add_purchase', data=dict(item="testItem", price=1.23, test1=50, testAddPurchasePostMember=49), follow_redirects=True) self.assertIn(b'Add a Purchase', response.data) group.delete_group("testAddPurchasePost") person.delete_user("testAddPurchasePostMember") person.remove_email_from_auth("*****@*****.**", "password")
def test_add_purchase_post_with_image(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testAddPurchasePost") person.delete_user("testAddPurchasePostMember") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'test1' session['group_name'] = 'testAddPurchasePost' group_member = Person("testAddPurchasePostMember", "testAddPurchasePostMember", "*****@*****.**", "testAddPurchasePostMember") response = client.post('/create_group', data=dict(group_name="testAddPurchasePost", selected_members=['testAddPurchasePostMember']), follow_redirects=True) response = client.post('/add_purchase', data=dict(image=(io.BytesIO(b"test bytes"), 'test.jpg'), item="testItem", price=1.23, test1=50, testAddPurchasePostMember=50), follow_redirects=True) self.assertIn(b'<b>Buyer: </b>test1', response.data) self.assertIn(b'<b>Item: </b>testItem', response.data) self.assertIn(b'<b>Cost: </b>1.23', response.data) group.delete_group("testAddPurchasePost") person.delete_user("testAddPurchasePostMember") person.remove_email_from_auth("*****@*****.**", "password")
def test_leave_group_invalid_group_name(self): p0 = Person("t0", "t0", "t0", "t0") p1 = Person("t1", "t1", "t1", "t1") p2 = Person("t2", "t2", "t2", "t2") p3 = Person("t3", "t3", "t3", "t3") Group("leave group", [p0, p1, p2, p3]) group.leave_group("leav group", "t1") self.assertRaises(Exception) group.delete_group("leave group")
def test_leave_group(self): p0 = Person("t0", "t0", "t0", "t0") p1 = Person("t1", "t1", "t1", "t1") p2 = Person("t2", "t2", "t2", "t2") p3 = Person("t3", "t3", "t3", "t3") Group("leave group", [p0, p1, p2, p3]) group.leave_group("leave group", "t1") self.assertEqual(3, len(group.get_all_users_in_group("leave group"))) group.delete_group("leave group")
def test_delete_purchase(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testDeletePurchaseGroup") person.delete_user("testDeletePurchase") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testDeletePurchase' session['group_name'] = 'testDeletePurchaseGroup' group_member = Person("testDeletePurchase", "testDeletePurchase", "*****@*****.**", "testDeletePurchase") group_member_2 = Person("testDeletePurchase2", "testDeletePurchase2", "*****@*****.**", "testDeletePurchase2") response = client.post('/create_group', data=dict(group_name="testDeletePurchaseGroup", selected_members=['testDeletePurchase2']), follow_redirects=True) response = client.post('/add_purchase', data=dict(item="testItem", price=1.23, testDeletePurchase=50, testDeletePurchase2=50), follow_redirects=True) self.assertEqual((['testItem'], ['testDeletePurchase'], ['1.23']), group.get_all_purchases_for_group("testDeletePurchaseGroup")) response = client.post('/add_purchase', data=dict(item="testItem2", price=1.24, testDeletePurchase=50, testDeletePurchase2=50), follow_redirects=True) self.assertEqual((['testItem', 'testItem2'], ['testDeletePurchase', 'testDeletePurchase'], ['1.23', '1.24']), group.get_all_purchases_for_group("testDeletePurchaseGroup")) response = client.post('/delete_purchase', data=dict(item_name="testItem"), follow_redirects=True) self.assertEqual((['testItem2'], ['testDeletePurchase'], ['1.24']), group.get_all_purchases_for_group("testDeletePurchaseGroup")) group.delete_group("testDeletePurchaseGroup") person.delete_user("testDeletePurchase") person.delete_user("testDeletePurchase2") person.remove_email_from_auth("*****@*****.**", "password") person.remove_email_from_auth("*****@*****.**", "password")
def test_delete_user(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testLeaveGroupUserGroup") person.delete_user("testDeleteUser") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testDeleteUser' user = Person("testDeleteUser", "testDeleteUser", "*****@*****.**", "testDeleteUser") response = client.get('/delete_user', follow_redirects=True) self.assertIn(b'Sign Up', response.data)
def test_create_group_post(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testCreateGroupPost") person.delete_user("testCreateGroupPostMember") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = "test1" group_member = Person("testCreateGroupPostMember", "testCreateGroupPostMember", "*****@*****.**", "testCreateGroupPostMember") response = client.post('/create_group', data=dict(group_name="testCreateGroupPost", selected_members=['testCreateGroupPostMember']), follow_redirects=True) self.assertIn(b'testCreateGroupPost', response.data) group.delete_group("testCreateGroupPost") person.delete_user("testCreateGroupPostMember") person.remove_email_from_auth("*****@*****.**", "password")
def test_venmo_display(self): flask_app = create_app() client = flask_app.test_client() with client.session_transaction() as session: session['is_logged'] = 'test1' session['group_name'] = 'testVenmoDisplayGroup' group_member = Person("testVenmoDisplay", "testVenmoDisplay", "*****@*****.**", "testVenmoDisplayVENMO") response = client.post('/create_group', data=dict(group_name="testVenmoDisplayGroup", selected_members=['testVenmoDisplay']), follow_redirects=True) response = client.get('/group', follow_redirects=True) self.assertIn(b'testVenmoDisplay', response.data) self.assertIn(b'Venmo: </b>testVenmoDisplayVENMO', response.data) group.delete_group("testVenmoDisplayGroup") person.delete_user("testVenmoDisplay") person.remove_email_from_auth("*****@*****.**", "password")
def test_leave_group_user_get(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testLeaveGroupUserGroup") person.delete_user("testLeaveGroupUser") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testLeaveGroupUser' session['group_name'] = 'testLeaveGroupUserGroup' group_member = Person("testLeaveGroupUser", "testLeaveGroupUser", "*****@*****.**", "testLeaveGroupUser") response = client.get('/leave_group_user', follow_redirects=True) self.assertIn(b'<h5 class="text-right" id="brand">testLeaveGroupUser</h5>', response.data) group.delete_group("testLeaveGroupUserGroup") person.delete_user("testLeaveGroupUser") person.remove_email_from_auth("*****@*****.**", "password")
def test_leave_group(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("testLeaveGroupGroup") person.delete_user("testLeaveGroup") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'testLeaveGroup' session['group_name'] = 'testLeaveGroupGroup' group_member = Person("testLeaveGroup", "testLeaveGroup", "*****@*****.**", "testLeaveGroup") response = client.get('/leave_group', follow_redirects=True) self.assertIn(b'Would you, testLeaveGroup, like to leave group testLeaveGroupGroup?', response.data) group.delete_group("testLeaveGroupGroup") person.delete_user("testLeaveGroup") person.remove_email_from_auth("*****@*****.**", "password")
def test_get_venmo(self): flask_app = create_app() client = flask_app.test_client() group.delete_group("groupGetVenmo") person.delete_user("testGetVenmoMember") person.remove_email_from_auth("*****@*****.**", "password") with client.session_transaction() as session: session['is_logged'] = 'test1' session['group_name'] = 'groupGetVenmo' group_member = Person("testGetVenmoMember", "testGetVenmoMember", "*****@*****.**", "testGetVenmoMember") response = client.post('/create_group', data=dict(group_name="groupGetVenmo", selected_members=['testGetVenmoMember']), follow_redirects=True) response = client.get('/get_venmo', follow_redirects=True) self.assertIn(b'List of Venmo Transactions For Group:', response.data) group.delete_group("groupGetVenmo") person.delete_user("testGetVenmoMember") person.remove_email_from_auth("*****@*****.**", "password")