From f815ae59f808637bf9d3fe79946c979fd152659e Mon Sep 17 00:00:00 2001 From: Manas Date: Jun 28 2019 09:35:24 +0000 Subject: change is to issue and us to userstory fixes #46 --- diff --git a/bz/pgba.py b/bz/pgba.py index 183178a..3b0a78e 100644 --- a/bz/pgba.py +++ b/bz/pgba.py @@ -12,7 +12,7 @@ from bz import bugs as bzbugs import bugzilla -def pgtobz(value, configpath): +def pgtobz(value, USERSTORY_id, configpath): config = configparser.ConfigParser() config.read(configpath) service_id = config['TAIGA']['SERVICE_ID'] # service id @@ -86,7 +86,7 @@ def pgtobz(value, configpath): assigned_to=bzid[0], cc=bzid[1:] ) - bzbugs.post_bug(createinfo, bzapi, config) + bug = bzbugs.post_bug(createinfo, bzapi, config) #print(r.content, r.status_code) # Development only #if r.status_code == 200: print("Sucessful Bugzilla Bug Creation") @@ -113,6 +113,17 @@ def pgtobz(value, configpath): if r.status_code == 200: print("Sucessful creation of issue on pagure release notes") return True + payload = { + "attributes_values": { + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: bug.weburl, + }, + "version": 2 + } + r = tgauserstory.post_usca(payload, USERSTORY_id, config) + if r.status_code == 200: + print("Sucessfully mapped bz to user story") + else: + print("check logs for errors") else: print("failed to complete acceptance") except requests.exceptions.RequestException as e: diff --git a/config.ini b/config.ini index c34551f..7d9da54 100644 --- a/config.ini +++ b/config.ini @@ -5,46 +5,46 @@ PROJECT_ID = 325667 TAIGA_URL = https://api.taiga.io TAIGA_SITE_ISSUE_URL = https://tree.taiga.io/project/pac_23-test-changes-tracker-kanban/issue/ -IS_STATUS_NEW = 2283176 -IS_STATUS_NEEDS_INFO = 2283180 -IS_STATUS_READY_FOR_WRANGLER = 2283232 -IS_STATUS_READY_FOR_FESCO = 2295359 -IS_STATUS_PROCESSED = 2283182 -US_STATUS_NEW = 1952887 -US_STATUS_ANNOUNCED = 1952888 -US_STATUS_R_FESCO = 1952889 -US_STATUS_ACCEPTED = 1952891 -US_STATUS_ARCHIVED = 1952890 -US_STATUS_CODE_COMPLETE = 1892839 -US_STATUS_TESTABLE = 1952932 +ISSUE_STATUS_NEW = 2283176 +ISSUE_STATUS_NEEDS_INFO = 2283180 +ISSUE_STATUS_READY_FOR_WRANGLER = 2283232 +ISSUE_STATUS_READY_FOR_FESCO = 2295359 +ISSUE_STATUS_PROCESSED = 2283182 +USERSTORY_STATUS_NEW = 1952887 +USERSTORY_STATUS_ANNOUNCED = 1952888 +USERSTORY_STATUS_R_FESCO = 1952889 +USERSTORY_STATUS_ACCEPTED = 1952891 +USERSTORY_STATUS_ARCHIVED = 1952890 +USERSTORY_STATUS_CODE_COMPLETE = 1892839 +USERSTORY_STATUS_TESTABLE = 1952932 -IS_CA_SYSTEM_WIDE_CHANGE = 11370 -IS_CA_SUMMARY = 11372 -IS_CA_BUGZILLA_CONTACT = 11373 -IS_CA_RELENG_TICKET = 11371 -IS_CA_TRADEMARK_APPROVAL = 11374 -IS_CA_OWNERS = 11375 -IS_CA_FESCO_TICKET = 534454574 -IS_CA_BUGZILLA_TRACKER = 21930 -IS_CA_RELEASE_NOTES = 21931 -IS_CA_CONTINGENCY = 11376 -IS_CA_MASS_REBUILD = 11377 -IS_CA_POLICY_CHANGE = 11378 -IS_CA_MODIFIES_DELIVERABLES = 11379 -IS_CA_VERSION = 11383 -US_CA_SYSTEM_WIDE_CHANGE = 21923 -US_cA_SUMMARY = 21924 -US_CA_BUGZILLA_CONTACT = 21925 -US_CA_RELENG_TICKET = 21926 -US_CA_TRADEMARK_APPROVAL = 21927 -US_CA_OWNERS = 21928 -US_CA_FESCO_TICKET = 21929 -US_CA_BUGZILLA_TRACKER = 21930 -US_CA_RELEASE_NOTES = 21931 -US_CA_CONTINGENCY = 21932 -US_CA_MASS_REBUILD = 21933 -US_CA_POLICY_CHANGE = 21934 -US_CA_MODIFIES_DELIVERABLES = 21935 +ISSUE_CA_SYSTEM_WIDE_CHANGE = 11370 +ISSUE_CA_SUMMARY = 11372 +ISSUE_CA_BUGZILLA_CONTACT = 11373 +ISSUE_CA_RELENG_TICKET = 11371 +ISSUE_CA_TRADEMARK_APPROVAL = 11374 +ISSUE_CA_OWNERS = 11375 +ISSUE_CA_FESCO_TICKET = 534454574 +ISSUE_CA_BUGZILLA_TRACKER = 21930 +ISSUE_CA_RELEASE_NOTES = 21931 +ISSUE_CA_CONTINGENCY = 11376 +ISSUE_CA_MASS_REBUILD = 11377 +ISSUE_CA_POLICY_CHANGE = 11378 +ISSUE_CA_MODIFIES_DELIVERABLES = 11379 +ISSUE_CA_VERSION = 11383 +USERSTORY_CA_SYSTEM_WIDE_CHANGE = 21923 +USERSTORY_CA_SUMMARY = 21924 +USERSTORY_CA_BUGZILLA_CONTACT = 21925 +USERSTORY_CA_RELENG_TICKET = 21926 +USERSTORY_CA_TRADEMARK_APPROVAL = 21927 +USERSTORY_CA_OWNERS = 21928 +USERSTORY_CA_FESCO_TICKET = 21929 +USERSTORY_CA_BUGZILLA_TRACKER = 21930 +USERSTORY_CA_RELEASE_NOTES = 21931 +USERSTORY_CA_CONTINGENCY = 21932 +USERSTORY_CA_MASS_REBUILD = 21933 +USERSTORY_CA_POLICY_CHANGE = 21934 +USERSTORY_CA_MODIFIES_DELIVERABLES = 21935 [PAGURE] diff --git a/tga/convert.py b/tga/convert.py index 2e317d0..abc95cc 100644 --- a/tga/convert.py +++ b/tga/convert.py @@ -118,28 +118,28 @@ def convert(value, configpath): if r.status_code == 201: print("step 3") data = json.loads(r.content) - us_id = data['id'] + USERSTORY_id = data['id'] print(id) payload = { "attributes_values": { - config['TAIGA']['US_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, - config['TAIGA']['US_CA_SUMMARY']: summary, - config['TAIGA']['US_CA_RELENG_TICKET']: relengticket, - config['TAIGA']['US_CA_TRADEMARK_APPROVAL']: approval_required, - #config['TAIGA']['US_CA_OWNERS']: owners, - config['TAIGA']['US_CA_FESCO_TICKET']: 'random', - config['TAIGA']['US_CA_BUGZILLA_TRACKER']: 'random', - config['TAIGA']['US_CA_BUGZILLA_CONTACT']: bugzilla_id, - config['TAIGA']['US_CA_RELEASE_NOTES']: 'random', - config['TAIGA']['US_CA_CONTINGENCY']: contingency_deadline, - config['TAIGA']['US_CA_MASS_REBUILD']: mass_rebuild, - config['TAIGA']['US_CA_POLICY_CHANGE']: policy_change, - config['TAIGA']['US_CA_MODIFIES_DELIVERABLES']: modifies_deliverables + config['TAIGA']['USERSTORY_CA_SYSTEM_WIDE_CHANGE']: system_wide_change, + config['TAIGA']['USERSTORY_CA_SUMMARY']: summary, + config['TAIGA']['USERSTORY_CA_RELENG_TICKET']: relengticket, + config['TAIGA']['USERSTORY_CA_TRADEMARK_APPROVAL']: approval_required, + #config['TAIGA']['USERSTORY_CA_OWNERS']: owners, + config['TAIGA']['USERSTORY_CA_FESCO_TICKET']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_TRACKER']: 'random', + config['TAIGA']['USERSTORY_CA_BUGZILLA_CONTACT']: bugzilla_id, + config['TAIGA']['USERSTORY_CA_RELEASE_NOTES']: 'random', + config['TAIGA']['USERSTORY_CA_CONTINGENCY']: contingency_deadline, + config['TAIGA']['USERSTORY_CA_MASS_REBUILD']: mass_rebuild, + config['TAIGA']['USERSTORY_CA_POLICY_CHANGE']: policy_change, + config['TAIGA']['USERSTORY_CA_MODIFIES_DELIVERABLES']: modifies_deliverables }, "version": 1 } print(payload) - r = tgauserstory.post_usca(payload, us_id, config) + r = tgauserstory.post_usca(payload, USERSTORY_id, config) print(json.loads(r.content)) print(r.status_code) if r.status_code == 200: @@ -154,11 +154,11 @@ def convert(value, configpath): epicref = i['ref'] break - r = tgaepic.post_relatedus(us_id, epicid, epicref, config) + r = tgaepic.post_relatedus(USERSTORY_id, epicid, epicref, config) if r.status_code == 201: print("Sucessfully mapped epics") payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } r = tgaissue.changestatus_issue(issue_id, payload, config) @@ -167,7 +167,7 @@ def convert(value, configpath): #print(json.loads(r.content)) if r.status_code == 200: print("Sucessfully closed issue") - return True + return True, USERSTORY_id else: print("Unsuccesful at closing issue,check logs") else: diff --git a/tga/epics.py b/tga/epics.py index d690a32..2d501f4 100644 --- a/tga/epics.py +++ b/tga/epics.py @@ -49,7 +49,7 @@ def list_epic(config): print(e) -def post_relatedus(us_id, epicid, epicref, config): +def post_relatedus(USERSTORY_id, epicid, epicref, config): try: """ config = configparser.ConfigParser() @@ -62,7 +62,7 @@ def post_relatedus(us_id, epicid, epicref, config): } payload = { "epic": epicid, - "user_story": us_id + "user_story": USERSTORY_id } r = requests.post( 'https://api.taiga.io/api/v1/epics/' + str(epicid) + '/related_userstories', diff --git a/tga/issues.py b/tga/issues.py index 729904b..bf8a59e 100644 --- a/tga/issues.py +++ b/tga/issues.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_IS_STATUS_NEW'] + status = config['TAIGA']['TEST_ISSUE_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['IS_STATUS_NEW'] + status = config['TAIGA']['ISSUE_STATUS_NEW'] else: print("please set test status in config") @@ -34,8 +34,7 @@ def list_issue(args): configpath = args.config config = configparser.ConfigParser() config.read(configpath) - - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['IS_STATUS_NEW']) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues?project=" + config['TAIGA']['PROJECT_ID'] + "\&status=" + str(config['TAIGA']['ISSUE_STATUS_NEW']) print(url) # Debug only headers = { 'Content-Type': 'application/json', @@ -63,8 +62,11 @@ def list_issue(args): print(table) else: print("Unable to fetch list check logs") + print(r.content) except requests.exceptions.RequestException as e: print(e) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,7 +132,7 @@ def changestatus_issue(x, payload, config): } """ payload = { - 'status': config['TAIGA']['IS_STATUS_PROCESSED'], + 'status': config['TAIGA']['ISSUE_STATUS_PROCESSED'], 'version': issue_version } """ diff --git a/tga/userstory b/tga/userstory deleted file mode 100644 index e69de29..0000000 --- a/tga/userstory +++ /dev/null diff --git a/tga/userstory.py b/tga/userstory.py index 9221cb6..c2f825b 100644 --- a/tga/userstory.py +++ b/tga/userstory.py @@ -13,10 +13,10 @@ project_id = config['TAIGA']['PROJECT_ID'] if config['TAIGA']['TEST'] == 'yes': taiga_url = config['TAIGA']['CUSTOM_TAIGA_URL'] - status = config['TAIGA']['TEST_US_STATUS_NEW'] + status = config['TAIGA']['TEST_USERSTORY_STATUS_NEW'] elif config['TAIGA']['TEST'] == 'no': taiga_url = config['TAIGA']['DEFAULT_TAIGA_URL'] - status = config['TAIGA']['US_STATUS_NEW'] + status = config['TAIGA']['USERSTORY_STATUS_NEW'] else: print("please set test status in config") @@ -39,6 +39,7 @@ def get_us(refusid, config): # 'Authorization': 'Bearer {0}'.format(str(123)) } url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories/by_ref?ref=" + str(refusid) + "\&project=" + str(config['TAIGA']['PROJECT_ID']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # debug only r = requests.get( url, @@ -49,18 +50,19 @@ def get_us(refusid, config): print(e) -def list_us(config): +def list_us(args): try: - """ + configpath = args.config config = configparser.ConfigParser() config.read(configpath) - """ headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(keyring.get_password(config['TAIGA']['SERVICE_TOKEN'], "taiga_token")) # 'Authorization': 'Bearer {0}'.format(str(123)) } - url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/issues/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['US_STATUS_NEW']) + print(headers) + url = str(config['TAIGA']['TAIGA_URL']) + "/api/v1/userstories?project=" + str(config['TAIGA']['PROJECT_ID']) + "\&status=" + str(config['TAIGA']['USERSTORY_STATUS_NEW']) + url = "https://api.taiga.io/api/v1/issues?project=325667\&status=2283176" print(url) # Debug only try: r = requests.get( @@ -68,23 +70,29 @@ def list_us(config): headers=headers ) if r.status_code == 200: + print(r.status_code) table = BeautifulTable() table.column_headers = ["refrence no", "subject", "fedora-version", "owner"] data = json.loads(r.content) for item in data: subject = item['subject'] - us_id = item['id'] - us_ref = item['ref'] + USERSTORY_id = item['id'] + USERSTORY_ref = item['ref'] version = item['epics'] duedate = item['due_date'] tags = ['tags'] for item in data['owner_extra_info']: owner = item['username'] - table.append_row([us_ref, subject, version, owner]) - #print(us_id, us_ref owner) + table.append_row([USERSTORY_ref, subject, version, owner]) + #print(USERSTORY_id, USERSTORY_ref owner) print(table) + else: + print(r.content) except requests.exceptions.RequestException as e: print(e) + print(r.content) + except Exception as e: + print(e) except Exception as e: print(e) @@ -130,3 +138,9 @@ def post_usca(x, id, config): return r except requests.exceptions.RequestException as e: print(e) +""" +curl -X GET \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer ${eyJ1c2VyX2F1dGhlbnRpY2F0aW9uX2lkIjozNTY4MDR9:1hI6pm:4d4mA-gUXC2S0FxaladX0Fd_3gA}" \ +-s https://api.taiga.io/api/v1/issues?project=325667\&status=2283176 +""" \ No newline at end of file