1
0
mirror of https://github.com/gryf/ferrit.git synced 2026-02-08 01:15:50 +01:00

Added more tests for change merged and comment added events

This commit is contained in:
2019-11-01 12:59:04 +01:00
parent 7338d4f5c3
commit fc46096cf2
4 changed files with 52 additions and 3 deletions

View File

@@ -4,6 +4,8 @@ import subprocess
import time
import unittest
import requests
class BaseTestCase(unittest.TestCase):
def setUp(self):
@@ -25,3 +27,24 @@ class BaseTestCase(unittest.TestCase):
os.killpg(self.process.pid, signal.SIGTERM)
os.unlink('ferrit-http.log')
os.unlink('ferrit-ssh.log')
def _send_and_get_response(self, event_type):
counter = 20
result = None
requests.post('http://localhost:8181/make/event',
data='type=%s' % event_type)
while counter:
if not os.path.exists('ferrit-http.log'):
counter -= 1
time.sleep(1)
continue
with open('ferrit-http.log') as fobj:
result = fobj.read()
if not result:
time.sleep(1)
counter -= 1
else:
break
return result

View File

@@ -0,0 +1,13 @@
import json
from tests import base
class TestChangeMerged(base.BaseTestCase):
def test_deploy(self):
result = self._send_and_get_response('change-merged')
self.assertTrue(result)
result = json.loads(result)
self.assertIn('--tag', result['message'])

View File

@@ -0,0 +1,13 @@
import json
from tests import base
class TestCommentAdded(base.BaseTestCase):
def test_recheck(self):
result = self._send_and_get_response('comment-added')
self.assertTrue(result)
result = json.loads(result)
self.assertEqual(result['labels']['Verified'], 1)