def test_getEventsByOrg_false(self): key = 999 eventListJSON = events.getEventsByOrgJSON(key) eventListDict = json.loads(eventListJSON) for rootKey, rootVal in eventListDict.iteritems(): self.assertEqual(rootKey, 'Events') self.assertEqual(rootVal, 'None')
def getEventsByOrg(org_id): try: eventListJSON = controller_events.getEventsByOrgJSON(org_id) eventListDict = json.loads(eventListJSON) org = controllers.getOrganizationByIDJSON(org_id) org_dict = json.loads(org) if is_request_json(): return jsonify(eventListDict, Organization=org_dict) except Exception, e: return abort(404)
def test_getEventsByOrg_true(self): key = 1 eventListJSON = events.getEventsByOrgJSON(key) eventListDict = json.loads(eventListJSON) for rootKey, rootVal in eventListDict.iteritems(): self.assertEqual(rootKey, 'Events') counter = 0 for eventJSON in rootVal: event = events.extractEventFromDict(eventJSON) if event.pk == 1: counter += 1 self.assertEqual(event.pk, 1) self.assertEqual(event.name, 'My Event') self.assertEqual(event.description, 'This is my event') self.assertEqual(event.organizationFK, key) self.assertEqual(counter, 1)