def test_find_record(self): cq = CQ(mockdata['base_url']) cq.open_session() try: res = cq.login(mockdata['loginId'], mockdata['password'], mockdata['repository']) resource_id = cq.find_record(mockdata['record_id']) resource_id2 = cq.find_record(mockdata['record_id2']) cq.logout() finally: cq.close_session() self.assertIsNotNone(resource_id) self.assertIsNone(resource_id2)
import unittest import getpass from pprint import pprint from libwebcq.CQ import CQ from libwebcq.error import SessionError from libwebcq.record import CustomerRecord, ModuleRecord, OwnerInfo, RecordType cq = CQ('http://avclearquest.qlogic.org/cqweb/') # Open a session befoer any network query. cq.open_session() try: # Need login before query protected resources. user = input('Enter your name: ') password = getpass.getpass(prompt="Enter CQ Password for " + user +": ") print(password) print("Login into Clearquest..."); res = cq.login(user, password, 'CQNew') res_id1 = cq.find_record('Cont00080744') record1 = cq.get_cq_record_details(res_id1, RecordType.CRP) #record1 = cq.get_cq_record_details(res_id1, RecordType.CUSTOMER) #record1 = cq.get_cq_record_details(res_id1, RecordType.USER) #record1 = cq.get_cq_record_details(res_id1, RecordType.MODULE) # Don't forget logout. pprint(vars(record1)) #print(record1.state) cq.logout() finally: # Close session when all work done. cq.close_session()
def test_get_record_details(self): cq = CQ(mockdata['base_url']) cq.open_session() try: res = cq.login(mockdata['loginId'], mockdata['password'], mockdata['repository']) resource_id = cq.find_record(mockdata['record_id']) record = cq.get_cq_record_details(resource_id, RecordType.CRP) cq.logout() finally: cq.close_session() expect = mockdata['record1'] self.assertIsNotNone( record, 'Record details for %s should not be None.' % mockdata['record_id']) self.assertEqual( expect['display_name'], record.display_name, 'The fetched record display name should equals the record id.') # Check module information. self.assertIsInstance( record.module, ModuleRecord, 'module field should be an instance of ModuleRecord.') self.assertEqual(expect['module']['display_name'], record.module.display_name, 'Module name is not equal.') self.assertEqual(expect['state'], record.state, 'State is not equal.') self.assertEqual(expect['last_op_date'], record.last_op_date, 'LastOpDate is not equal.') # Check owner information. self.assertIsInstance( record.owner_info, OwnerInfo, 'owner_info field should be an instance of OwnerInfo.') self.assertEqual(expect['owner_info']['tel'], record.owner_info.tel, 'Owner tel is not equal.') self.assertEqual(expect['owner_info']['email'], record.owner_info.email, 'Owner email is not equal.') self.assertEqual(expect['open_duration'], record.open_duration, 'OpenDuration is not equal.') # Check custom. self.assertIsInstance( record.customer, CustomerRecord, 'customer field should be an instance of CustomerRecord.') self.assertEqual(expect['customer']['display_name'], record.customer.display_name, 'Customer name is not equal.') self.assertEqual(expect['customer']['record_id'], record.customer.record_id, 'Customer record id is not equal.') self.assertEqual(expect['customer']['stable_location'], record.customer.stable_location, 'Customer stable location is not equal.') self.assertEqual(expect['version_base_on'], record.version_base_on, 'VersionBaseOn is not equal.') self.assertEqual(expect['id'], record.id, 'id is not equal.') self.assertEqual(expect['headline'], record.headline, 'Headline is not equal.') self.assertEqual(expect['customer_phone'], record.customer_phone, 'CustomerPhone is not equal.') self.assertListEqual(expect['custom_emails'], record.custom_emails, 'CustomEmails is not equal.')