#1161 frontend: tests for pagure events
Merged 4 years ago by praiskup. Opened 4 years ago by schlupov.
copr/ schlupov/copr test_pagure_events  into  master

frontend: tests for pagure events
Silvie Chlupova • 4 years ago  
@@ -63,3 +63,9 @@ 

  # %check section start redis-server on this port

  REDIS_HOST = "127.0.0.1"

  REDIS_PORT = 7777

+ 

+ PAGURE_EVENTS = {

+   'io.pagure.prod.pagure.git.receive' : 'https://pagure.io/',

+   'io.pagure.prod.pagure.pull-request.new' : 'https://pagure.io/',

+   'io.pagure.prod.pagure.pull-request.comment.added' : 'https://pagure.io/',

+ }

@@ -0,0 +1,52 @@ 

+ from pagure_events import event_info_from_pr_comment, event_info_from_push, event_info_from_pr

+ from tests.coprs_test_case import CoprsTestCase

+ 

+ 

+ class TestPagureEvents(CoprsTestCase):

+     data = {

+         "msg": {

+             "agent": "test",

+             "pullrequest": {

+                 "branch": "master",

+                 "branch_from": "test_PR",

+                 "id": 1,

+                 "commit_start": "78a74b02771506daf8927b3391a669cbc32ccf10",

+                 "commit_stop": "da3d120f2ff24fa730067735c19a0b52c8bc1a44",

+                 "repo_from": {

+                     "fullname": "test/copr/copr",

+                     "url_path": "test/copr/copr",

+                 },

+                 "project": {

+                     "fullname": "test/copr/copr",

+                     "url_path": "test/copr/copr",

+                 },

+                 'status': 'Open',

+                 "comments": []

+             }

+         }

+     }

+     base_url = "https://pagure.io/"

+ 

+     def test_negative_event_info_from_pr_comment(self):

+         event_info = event_info_from_pr_comment(self.data, self.base_url)

+         assert not event_info

+ 

+     def test_positive_event_info_from_pr_comment(self):

+         self.data['msg']['pullrequest']["comments"].append({"comment": "[copr-build]"})

+         event_info = event_info_from_pr_comment(self.data, self.base_url)

+         assert event_info.base_clone_url == "https://pagure.io/test/copr/copr"

+ 

+     def test_positive_event_info_from_pr(self):

+         event_info = event_info_from_pr(self.data, self.base_url)

+         assert event_info.base_clone_url == "https://pagure.io/test/copr/copr"

+ 

+     def test_positive_event_info_from_push(self):

+         self.data['msg'] = {

+             "branch": "master",

+             "start_commit": "61bba3a6bd95fe83c651339018c1d36eae48b620",

+             'end_commit': '61bba3a6bd95fe83c651339018c1d36eae48b620',

+             "agent": "test"

+         }

+         self.data['msg']['repo'] = {"fullname": "test", "url_path": "test"}

+         event_info = event_info_from_push(self.data, self.base_url)

+         assert event_info.base_clone_url == "https://pagure.io/test"

Nice, thank you. Can we please have two more tests,
- one checking that build is submitted for push, and
- one checking that build is submitted for PR update?

Nice, thank you. Can we please have two more tests,
- one checking that build is submitted for push, and
- one checking that build is submitted for PR update?

Metadata Update from @praiskup:
- Pull-request tagged with: needs-work

4 years ago

+1 anyways, those two can be added in new PR

rebased onto 2e1d28b

4 years ago

Pull-Request has been merged by praiskup

4 years ago