def test_putPersonInOrganization(self): self.resetDB() # Sub-Test 1: Invalid person key. # Define prerequisite data. personKey = 9999 request = '{"org_id": 1}' # Get the result of the tested method. result = controllers.putPersonInOrganization(request, self.db, personKey) # Validate the result. self.assertFalse(result) # Sub-Test 2: Invalid json. # Define prerequisite data. request = 'xxx' personKey = 4 # Get the result of the tested method. result = controllers.putPersonInOrganization(request, self.db, personKey) # Validate the result. self.assertFalse(result) # Sub-Test 3: Invalid organization key. # Define prerequisite data. personKey = 4 request = {org_id: 9999} # Get the result of the tested method. result = controllers.putPersonInOrganization(request, self.db, personKey) # Validate the result. self.assertFalse(result) # Sub-Test 4: Valid execution. # Define prerequisite data. personKey = 4 request = {org_id: 1} # Get the result of the tested method. result = controllers.putPersonInOrganization(request, self.db, personKey) # Validate the result. self.assertTrue(result) # Sub-Test 5: Duplicate member. # Define prerequisite data. # use same data as before # Get the result of the tested method. result = controllers.putPersonInOrganization(request, self.db, personKey) # Validate the result. self.assertTrue(result) self.resetDB()
def join_org(org_id): if request.method == 'POST' and is_request_json(): request.data # Reading the data will avoid uwsgi bug. Thanks to Jasdeep(Sunny) Bhumber. result = controllers.putPersonInOrganization(org_id, db, current_user.get_id()) return Response(response=result, mimetype='application/json') else: return jsonify(msg='Other request method[%s]' % request.method)