def process_calls(): """ Go through all "Back Office Third Party/CSC" calls, classifying if open or closed :return: """ try: sdplus_api = API(os.environ['SDPLUS_ADMIN'], 'http://sdplus/sdpapi/') if not sdplus_api: raise KeyError except KeyError: print( 'Windows environment varible for "SDPLUS_ADMIN" (the API key for sdplus) wasn\'t found. \n' 'Please correct using ""setx SDPLUS_ADMIN <insert your own SDPLUS key here>" in a command line.' ) sys.exit(1) result = [] all_queues = sdplus_api.request_get_requests( 'Back Office Third Party/CSC_QUEUE') for each_call in all_queues: conversations = sdplus_api.request_get_all_conversations( each_call['workorderid']) each_call['classification'] = classify_call(conversations) each_call['Others involved'] = find_all_people_involved( conversations, each_call['requester']) each_call['CSC open/reopen date'] = find_date_csc_opened_call( conversations) each_call['CSC severity'] = find_csc_severity(conversations) result.append(each_call) return result
class RequestGeneralTest(unittest.TestCase): def setUp(self): self.sdplus_api = API(sdplus_api_key, sdplus_base_url) def test_requests_get_requests(self): result = self.sdplus_api.request_get_requests() self.assertEqual(result['response_status'], 'Success') def test_request_get_request_filters(self): result = self.sdplus_api.request_get_request_filters() self.assertEqual(result['response_status'], 'Success')