Ejemplo n.º 1
0
 def test_multiple_labels(self):
     payload = {
         "assignee": {
             "login": "******",
             "html_url": "http://news.com"
         },
         "labels": [
             {
                 "url": "label.com",
                 "name": "label name",
                 "color": "red"
             },
             {
                 "url": "label2.com",
                 "name": "label2 name",
                 "color": "blue"
             }
         ]
     }
     expected_labels = [
         GithubIssueLabel(url="label.com", name="label name", color="red"),
         GithubIssueLabel(url="label2.com",
                          name="label2 name",
                          color="blue")
     ]
     self.ghi.load(payload)
     self.assertEqual(self.ghi.title, "No Title")
     self.assertEqual(self.ghi.html_url, "")
     self.assertEqual(self.ghi.state, "")
     self.assertEqual(self.ghi.assignee,
                      GithubUser(login="******",
                                 html_url="http://news.com"))
     self.assertEqual(self.ghi.labels, expected_labels)
     self.assertEqual(self.ghi.user, GithubUser())
Ejemplo n.º 2
0
 def test_default_setup(self):
     self.assertEqual(self.ghi.title, "No Title")
     self.assertEqual(self.ghi.html_url, "")
     self.assertEqual(self.ghi.state, "")
     self.assertEqual(self.ghi.assignee, GithubUser())
     self.assertEqual(self.ghi.labels, [])
     self.assertEqual(self.ghi.user, GithubUser())
Ejemplo n.º 3
0
 def __init__(self, **kwargs):
     super(PullRequest, self).__init__(**kwargs)
     if not self.title:
         self.title = "[No Title]"
     if not self.user:
         self.user = GithubUser()
     if not self.merged:
         self.merged = False
Ejemplo n.º 4
0
 def test_load_empty_secondary_objects(self):
     payload = {}
     self.ghi.load(payload)
     self.assertEqual(self.ghi.title, "No Title")
     self.assertEqual(self.ghi.html_url, "")
     self.assertEqual(self.ghi.state, "")
     self.assertEqual(self.ghi.assignee, GithubUser())
     self.assertEqual(self.ghi.labels, [])
     self.assertEqual(self.ghi.user, GithubUser())
Ejemplo n.º 5
0
    def load(self, object_dict):
        for prop in ["title", "html_url", "state", "merged"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_user = object_dict.get('user', None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 6
0
 def __init__(self, **kwargs):
     super(GithubIssue, self).__init__(**kwargs)
     if not self.title:
         self.title = "No Title"
     if not self.assignee:
         self.assignee = GithubUser()
     if not self.labels:
         self.labels = []
     if not self.user:
         self.user = GithubUser()
Ejemplo n.º 7
0
 def __init__(self, **kwargs):
     super(GithubIssue, self).__init__(**kwargs)
     if not self.title:
         self.title = "No Title"
     if not self.assignee:
         self.assignee = GithubUser()
     if not self.labels:
         self.labels = []
     if not self.user:
         self.user = GithubUser()
Ejemplo n.º 8
0
    def load(self, object_dict):
        self.action = object_dict.get('action', self.action)

        gh_issue = object_dict.get('issue', None)
        self.issue = GithubIssue()
        if gh_issue:
            self.issue.load(gh_issue)

        gh_user = object_dict.get('sender', None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 9
0
    def load(self, object_dict):
        self.action = object_dict.get('action', self.action)
        self.number = object_dict.get('number', self.number)

        gh_pr = object_dict.get('pull_request', None)
        self.pull_request = PullRequest()
        if gh_pr:
            self.pull_request.load(gh_pr)

        gh_user = object_dict.get('sender', None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 10
0
 def test_load_empty_secondary_objects(self):
     payload = {}
     self.ghpre.load(payload)
     self.assertEqual(self.ghpre.action, "<No Action Specified>")
     self.assertEqual(self.ghpre.number, "")
     self.assertEqual(self.ghpre.pull_request, PullRequest())
     self.assertEqual(self.ghpre.sender, GithubUser())
Ejemplo n.º 11
0
 def test_non_empty_pr(self):
     payload = {"action": "sleep", "pull_request": {"title": "new pr"}}
     self.ghpre.load(payload)
     self.assertEqual(self.ghpre.action, "sleep")
     self.assertEqual(self.ghpre.number, "")
     self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr"))
     self.assertEqual(self.ghpre.sender, GithubUser())
Ejemplo n.º 12
0
 def test_non_empty_assignee(self):
     payload = {
         "assignee": {
             "login": "******",
             "html_url": "http://news.com"
         }
     }
     self.ghi.load(payload)
     self.assertEqual(self.ghi.title, "No Title")
     self.assertEqual(self.ghi.html_url, "")
     self.assertEqual(self.ghi.state, "")
     self.assertEqual(self.ghi.assignee,
                      GithubUser(login="******",
                                 html_url="http://news.com"))
     self.assertEqual(self.ghi.labels, [])
     self.assertEqual(self.ghi.user, GithubUser())
Ejemplo n.º 13
0
 def __init__(self, **kwargs):
     super(PullRequest, self).__init__(**kwargs)
     if not self.title:
         self.title = "[No Title]"
     if not self.user:
         self.user = GithubUser()
     if not self.merged:
         self.merged = False
Ejemplo n.º 14
0
 def test_load_empty_secondary_objects(self):
     payload = {}
     self.ghpr.load(payload)
     self.assertEqual(self.ghpr.title, "[No Title]")
     self.assertEqual(self.ghpr.html_url, "")
     self.assertEqual(self.ghpr.state, "")
     self.assertEqual(self.ghpr.merged, False)
     self.assertEqual(self.ghpr.user, GithubUser())
Ejemplo n.º 15
0
    def load(self, object_dict):
        for prop in ["title", "html_url", "state", "merged"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_user = object_dict.get("user", None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 16
0
    def load(self, object_dict):
        for prop in ["title", "html_url", "state"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_assignee = object_dict.get('assignee', None)
        self.assignee = GithubUser()
        if gh_assignee:
            self.assignee.load(gh_assignee)

        gh_labels = object_dict.get('labels', [])
        self.labels = []
        for label in gh_labels:
            t_label = GithubIssueLabel()
            t_label.load(label)
            self.labels.append(t_label)

        gh_user = object_dict.get('user', None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 17
0
    def load(self, object_dict):
        for prop in ["title", "html_url", "state"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_assignee = object_dict.get("assignee", None)
        self.assignee = GithubUser()
        if gh_assignee:
            self.assignee.load(gh_assignee)

        gh_labels = object_dict.get("labels", [])
        self.labels = []
        for label in gh_labels:
            t_label = GithubIssueLabel()
            t_label.load(label)
            self.labels.append(t_label)

        gh_user = object_dict.get("user", None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 18
0
    def load(self, object_dict):
        self.action = object_dict.get("action", self.action)
        self.number = object_dict.get("number", self.number)

        gh_pr = object_dict.get("pull_request", None)
        self.pull_request = PullRequest()
        if gh_pr:
            self.pull_request.load(gh_pr)

        gh_user = object_dict.get("sender", None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 19
0
class PullRequest(BaseObject):

    properties = ["html_url", "state", "title", "user", "merged"]

    def __init__(self, **kwargs):
        super(PullRequest, self).__init__(**kwargs)
        if not self.title:
            self.title = "[No Title]"
        if not self.user:
            self.user = GithubUser()
        if not self.merged:
            self.merged = False

    def load(self, object_dict):
        for prop in ["title", "html_url", "state", "merged"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_user = object_dict.get("user", None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 20
0
class PullRequest(BaseObject):

    properties = ['html_url', 'state', 'title', 'user', 'merged']

    def __init__(self, **kwargs):
        super(PullRequest, self).__init__(**kwargs)
        if not self.title:
            self.title = "[No Title]"
        if not self.user:
            self.user = GithubUser()
        if not self.merged:
            self.merged = False

    def load(self, object_dict):
        for prop in ["title", "html_url", "state", "merged"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_user = object_dict.get('user', None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 21
0
 def test_non_empty_user(self):
     payload = {
         "user": {
             "login": "******",
             "html_url": "u2.com"
         },
     }
     self.ghpr.load(payload)
     self.assertEqual(self.ghpr.title, "[No Title]")
     self.assertEqual(self.ghpr.html_url, "")
     self.assertEqual(self.ghpr.state, "")
     self.assertEqual(self.ghpr.merged, False)
     self.assertEqual(self.ghpr.user,
                      GithubUser(login="******", html_url="u2.com"))
Ejemplo n.º 22
0
class PullRequestEvent(BaseObject):

    properties = ['action', 'number', 'pull_request', 'sender']

    def __init__(self, **kwargs):
        super(PullRequestEvent, self).__init__(**kwargs)
        self.action = "<No Action Specified>"
        self.pull_request = PullRequest()
        self.sender = GithubUser()

    def load(self, object_dict):
        self.action = object_dict.get('action', self.action)
        self.number = object_dict.get('number', self.number)

        gh_pr = object_dict.get('pull_request', None)
        self.pull_request = PullRequest()
        if gh_pr:
            self.pull_request.load(gh_pr)

        gh_user = object_dict.get('sender', None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 23
0
class PullRequestEvent(BaseObject):

    properties = ["action", "number", "pull_request", "sender"]

    def __init__(self, **kwargs):
        super(PullRequestEvent, self).__init__(**kwargs)
        self.action = "<No Action Specified>"
        self.pull_request = PullRequest()
        self.sender = GithubUser()

    def load(self, object_dict):
        self.action = object_dict.get("action", self.action)
        self.number = object_dict.get("number", self.number)

        gh_pr = object_dict.get("pull_request", None)
        self.pull_request = PullRequest()
        if gh_pr:
            self.pull_request.load(gh_pr)

        gh_user = object_dict.get("sender", None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 24
0
 def test_non_empty_sender(self):
     payload = {
         "action": "sleep",
         "issue": {
             "title": "new issue"
         },
         "sender": {
             "login": "******"
         }
     }
     self.ghie.load(payload)
     self.assertEqual(self.ghie.action, "sleep")
     self.assertEqual(self.ghie.issue, GithubIssue(title="new issue"))
     self.assertEqual(self.ghie.sender, GithubUser(login="******"))
Ejemplo n.º 25
0
class GithubIssue(BaseObject):

    properties = ['title', 'html_url', 'assignee', 'state', 'labels', 'user']

    def __init__(self, **kwargs):
        super(GithubIssue, self).__init__(**kwargs)
        if not self.title:
            self.title = "No Title"
        if not self.assignee:
            self.assignee = GithubUser()
        if not self.labels:
            self.labels = []
        if not self.user:
            self.user = GithubUser()

    def load(self, object_dict):
        for prop in ["title", "html_url", "state"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_assignee = object_dict.get('assignee', None)
        self.assignee = GithubUser()
        if gh_assignee:
            self.assignee.load(gh_assignee)

        gh_labels = object_dict.get('labels', [])
        self.labels = []
        for label in gh_labels:
            t_label = GithubIssueLabel()
            t_label.load(label)
            self.labels.append(t_label)

        gh_user = object_dict.get('user', None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 26
0
class GithubIssueEvent(BaseObject):

    properties = [
        'action',
        'issue',
        'sender'
    ]

    def __init__(self, **kwargs):
        super(GithubIssueEvent, self).__init__(**kwargs)
        self.action = "<No Action Specified>"

    def load(self, object_dict):
        self.action = object_dict.get('action', self.action)

        gh_issue = object_dict.get('issue', None)
        self.issue = GithubIssue()
        if gh_issue:
            self.issue.load(gh_issue)

        gh_user = object_dict.get('sender', None)
        self.sender = GithubUser()
        if gh_user:
            self.sender.load(gh_user)
Ejemplo n.º 27
0
class GithubIssue(BaseObject):

    properties = ["title", "html_url", "assignee", "state", "labels", "user"]

    def __init__(self, **kwargs):
        super(GithubIssue, self).__init__(**kwargs)
        if not self.title:
            self.title = "No Title"
        if not self.assignee:
            self.assignee = GithubUser()
        if not self.labels:
            self.labels = []
        if not self.user:
            self.user = GithubUser()

    def load(self, object_dict):
        for prop in ["title", "html_url", "state"]:
            default = getattr(self, prop)
            setattr(self, prop, object_dict.get(prop, default))

        gh_assignee = object_dict.get("assignee", None)
        self.assignee = GithubUser()
        if gh_assignee:
            self.assignee.load(gh_assignee)

        gh_labels = object_dict.get("labels", [])
        self.labels = []
        for label in gh_labels:
            t_label = GithubIssueLabel()
            t_label.load(label)
            self.labels.append(t_label)

        gh_user = object_dict.get("user", None)
        self.user = GithubUser()
        if gh_user:
            self.user.load(gh_user)
Ejemplo n.º 28
0
 def test_non_empty_sender(self):
     payload = {
         "action": "sleep",
         "number": "42",
         "pull_request": {
             "title": "new pr"
         },
         "sender": {
             "login": "******"
         }
     }
     self.ghpre.load(payload)
     self.assertEqual(self.ghpre.action, "sleep")
     self.assertEqual(self.ghpre.number, "42")
     self.assertEqual(self.ghpre.pull_request, PullRequest(title="new pr"))
     self.assertEqual(self.ghpre.sender, GithubUser(login="******"))
Ejemplo n.º 29
0
 def test_default_setup(self):
     self.assertEqual(self.ghpre.action, "<No Action Specified>")
     self.assertEqual(self.ghpre.number, "")
     self.assertEqual(self.ghpre.pull_request, PullRequest())
     self.assertEqual(self.ghpre.sender, GithubUser())
Ejemplo n.º 30
0
 def test_default_setup(self):
     self.assertEqual(self.ghpr.title, "[No Title]")
     self.assertEqual(self.ghpr.html_url, "")
     self.assertEqual(self.ghpr.state, "")
     self.assertEqual(self.ghpr.merged, False)
     self.assertEqual(self.ghpr.user, GithubUser())
Ejemplo n.º 31
0
 def __init__(self, **kwargs):
     super(PullRequestEvent, self).__init__(**kwargs)
     self.action = "<No Action Specified>"
     self.pull_request = PullRequest()
     self.sender = GithubUser()
Ejemplo n.º 32
0
 def __init__(self, **kwargs):
     super(PullRequestEvent, self).__init__(**kwargs)
     self.action = "<No Action Specified>"
     self.pull_request = PullRequest()
     self.sender = GithubUser()
Ejemplo n.º 33
0
 def test_load_empty_secondary_objects(self):
     payload = {}
     self.ghie.load(payload)
     self.assertEqual(self.ghie.action, "<No Action Specified>")
     self.assertEqual(self.ghie.issue, GithubIssue())
     self.assertEqual(self.ghie.sender, GithubUser())