more changes
This commit is contained in:
parent
0385d75afb
commit
5e35a1c443
|
@ -3,4 +3,6 @@ from todoist_interface.gitlab import GitlabAPI
|
||||||
|
|
||||||
def test_gitlab_init():
|
def test_gitlab_init():
|
||||||
gitlab = GitlabAPI("url", "token", "assignee")
|
gitlab = GitlabAPI("url", "token", "assignee")
|
||||||
assert gitlab.url == "url" and gitlab.token == "token"
|
assert (gitlab.url == "url"
|
||||||
|
and gitlab.token == "token"
|
||||||
|
and gitlab.assignee == "assignee")
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
from todoist_interface.mantishub import MantishubAPI
|
||||||
|
|
||||||
|
|
||||||
|
def test_mantishub_init():
|
||||||
|
mantishub = MantishubAPI("mantistoken")
|
||||||
|
assert mantishub.token == "mantistoken"
|
||||||
|
|
||||||
|
|
||||||
|
def test_mantishub_get_tickets():
|
||||||
|
mantishub = MantishubAPI("mantistoken")
|
||||||
|
tickets = mantishub.get_tickets()
|
||||||
|
assert len(tickets) > 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_convert_to_todoist():
|
||||||
|
assert False
|
|
@ -18,15 +18,26 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Get the Todoist tasks
|
# Get the Todoist tasks
|
||||||
tasks = []
|
tasks = []
|
||||||
tasks.append(todoist.get_get_tasks_by_filter("@gitlab"))
|
|
||||||
tasks.append(todoist.get_get_tasks_by_filter("@mantis"))
|
gitlab_labeled_tasks = todoist.get_get_tasks_by_filter("@gitlab")
|
||||||
|
if gitlab_labeled_tasks:
|
||||||
|
tasks.append(gitlab_labeled_tasks)
|
||||||
|
|
||||||
|
mantis_labeled_tasks = todoist.get_get_tasks_by_filter("@mantis")
|
||||||
|
if mantis_labeled_tasks:
|
||||||
|
tasks.append(mantis_labeled_tasks)
|
||||||
|
|
||||||
# Get the Gitlab issues
|
# Get the Gitlab issues
|
||||||
gitlab_tasks = gitlab.get_issues()
|
# gitlab_tasks = gitlab.get_issues()
|
||||||
|
gitlab_tasks = []
|
||||||
|
|
||||||
mantishub_tasks = mantishub.get_tickets()
|
mantishub_tasks = mantishub.get_tickets()
|
||||||
missing_tasks = []
|
missing_tasks = []
|
||||||
missing_tasks.append(utils.get_missing_tasks(tasks, gitlab_tasks))
|
if gitlab_tasks:
|
||||||
missing_tasks.append(utils.get_missing_tasks(tasks, mantishub_tasks))
|
missing_tasks.append(utils.get_missing_tasks(tasks, gitlab_tasks))
|
||||||
|
|
||||||
|
if mantishub_tasks:
|
||||||
|
missing_tasks.append(utils.get_missing_tasks(tasks, mantishub_tasks))
|
||||||
|
|
||||||
if missing_tasks:
|
if missing_tasks:
|
||||||
todoist.create_tasks(missing_tasks)
|
todoist.create_tasks(missing_tasks)
|
||||||
|
|
|
@ -12,14 +12,14 @@ class MantishubAPI:
|
||||||
self.url + "issues?filter_id=assigned",
|
self.url + "issues?filter_id=assigned",
|
||||||
headers={"Authorization": self.token})
|
headers={"Authorization": self.token})
|
||||||
tickets = response.json()
|
tickets = response.json()
|
||||||
return self.convert_to_todoist(tickets)
|
return self.convert_to_todoist(tickets["issues"])
|
||||||
|
|
||||||
def convert_to_todoist(self, tickets):
|
def convert_to_todoist(self, tickets):
|
||||||
# TODO: add a function to convert mantis priority to todoist priority
|
# TODO: add a function to convert mantis priority to todoist priority
|
||||||
# TODO: add a function to create the url
|
|
||||||
tasks = []
|
tasks = []
|
||||||
for ticket in tickets:
|
for ticket in tickets:
|
||||||
url = "https:mantishub.com"
|
url = ("https://contria.mantishub.io/view.php?id="
|
||||||
|
+ str(ticket["id"]))
|
||||||
content = "[{title}]({url})".format(title=ticket["summary"],
|
content = "[{title}]({url})".format(title=ticket["summary"],
|
||||||
url=url)
|
url=url)
|
||||||
tasks.append({"content": content, "label_ids": [2158784659, ]})
|
tasks.append({"content": content, "label_ids": [2158784659, ]})
|
||||||
|
|
|
@ -6,8 +6,11 @@ def get_missing_tasks(tasks, issues_to_check):
|
||||||
:return: A list of tasks not in Todoist
|
:return: A list of tasks not in Todoist
|
||||||
"""
|
"""
|
||||||
missing_tasks = []
|
missing_tasks = []
|
||||||
for issue in issues_to_check:
|
if tasks:
|
||||||
if issue["content"] not in [t["content"] for t in tasks]:
|
for issue in issues_to_check:
|
||||||
missing_tasks.append(issue)
|
if issue["content"] not in [t["content"] for t in tasks]:
|
||||||
|
missing_tasks.append(issue)
|
||||||
|
else:
|
||||||
|
missing_tasks = issues_to_check
|
||||||
|
|
||||||
return missing_tasks
|
return missing_tasks
|
||||||
|
|
Loading…
Reference in New Issue