示例#1
0
    def test_create_from_json(self):
        commits = GitHubCommit.create_from_json(self.env, JSON_COMMITS, git_url=GIT_URL)
        for x in range(2):
            commit = commits.next()
            eq_(self.env, commit.env)
            eq_(COMMITS[x]["id"], commit.id)
            eq_(COMMITS[x]["url"], commit.url)
            eq_(COMMITS[x]["message"], commit.message)
            eq_(COMMITS[x]["author"]["name"], commit.name)
            eq_(COMMITS[x]["author"]["email"], commit.email)
            ok_(not commit.is_clone())

        commits.next()  # should raise an exception
示例#2
0
 def process_request(self, req):
     """
     Parse Github post and call all components implementing IGitHubPostObserver.
     """
     msg = 'ok'
     status = 200
     db = self.env.get_db_cnx()
     try:
         json = req.args.get('payload')
         for commit in GitHubCommit.create_from_json(self.env, json, git_url=self.github_url, db=db):
             self.env.log.debug("Calling observer(s) for commit: %s" % commit.url)
             for observer in self.observers:
                 observer.process_commit(commit)
             
     except (GitHubCommitException), e:
         db.rollback()
         self.env.log.error('An error occurred: %s' % str(e))
         msg = 'An error occurred: %s' % str(e)
         status = 404