Browse Source

Merge "pagure: ensure files is list and not a dict_keys"

changes/83/703983/7
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
b34f9ffe34
4 changed files with 51 additions and 5 deletions
  1. +4
    -4
      tests/base.py
  2. +24
    -0
      tests/fixtures/layouts/files-pagure.yaml
  3. +22
    -0
      tests/unit/test_pagure_driver.py
  4. +1
    -1
      zuul/driver/pagure/pagureconnection.py

+ 4
- 4
tests/base.py View File

@@ -1131,7 +1131,7 @@ class FakePagurePullRequest(object):
log = logging.getLogger("zuul.test.FakePagurePullRequest")

def __init__(self, pagure, number, project, branch,
subject, upstream_root, files=[], number_of_commits=1,
subject, upstream_root, files={}, number_of_commits=1,
initial_comment=None):
self.pagure = pagure
self.source = pagure
@@ -1291,17 +1291,17 @@ class FakePagurePullRequest(object):
return PagureChangeReference.create(
repo, self.getPRReference(), 'refs/tags/init')

def addCommit(self, files=[]):
def addCommit(self, files={}):
"""Adds a commit on top of the actual PR head."""
self._addCommitInPR(files=files)
self._updateTimeStamp()

def forcePush(self, files=[]):
def forcePush(self, files={}):
"""Clears actual commits and add a commit on top of the base."""
self._addCommitInPR(files=files, reset=True)
self._updateTimeStamp()

def _addCommitInPR(self, files=[], reset=False):
def _addCommitInPR(self, files={}, reset=False):
repo = self._getRepo()
ref = repo.references[self.getPRReference()]
if reset:


+ 24
- 0
tests/fixtures/layouts/files-pagure.yaml View File

@@ -0,0 +1,24 @@
- pipeline:
name: check
manager: independent
trigger:
pagure:
- event: pg_pull_request
action: opened

- job:
name: base
parent: null
run: playbooks/base.yaml

- job:
name: project-test1
files:
- .*-requires
run: playbooks/project-test1.yaml

- project:
name: org/project
check:
jobs:
- project-test1

+ 22
- 0
tests/unit/test_pagure_driver.py View File

@@ -284,6 +284,28 @@ class TestPagureDriver(ZuulTestCase):
], ordered=False
)

@simple_layout('layouts/files-pagure.yaml', driver='pagure')
def test_pull_matched_file_event(self):
A = self.fake_pagure.openFakePullRequest(
'org/project', 'master', 'A',
files={'random.txt': 'test', 'build-requires': 'test'})
self.fake_pagure.emitEvent(A.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(1, len(self.history))

B = self.fake_pagure.openFakePullRequest('org/project', 'master', 'B',
files={'random.txt': 'test2'})
self.fake_pagure.emitEvent(B.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(1, len(self.history))

C = self.fake_pagure.openFakePullRequest(
'org/project', 'master', 'C',
files={'build-requires': 'test'})
self.fake_pagure.emitEvent(C.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(2, len(self.history))

@simple_layout('layouts/basic-pagure.yaml', driver='pagure')
def test_tag_created(self):



+ 1
- 1
zuul/driver/pagure/pagureconnection.py View File

@@ -757,7 +757,7 @@ class PagureConnection(BaseConnection):
pagure = self.get_project_api_client(project_name)
pr = pagure.get_pr(number)
diffstats = pagure.get_pr_diffstats(number)
pr['files'] = diffstats.keys()
pr['files'] = list(diffstats.keys())
self.log.info('Got PR %s#%s', project_name, number)
return pr



Loading…
Cancel
Save