openSUSE-release-tools/tests/accept_tests.py

39 lines
1.3 KiB
Python
Raw Normal View History

import unittest
from . import obs
from osclib.accept_command import AcceptCommand
from osclib.conf import Config
from osclib.comments import CommentAPI
from osclib.stagingapi import StagingAPI
2014-06-23 15:03:16 +02:00
class TestAccept(unittest.TestCase):
def setUp(self):
"""
Initialize the configuration
"""
self.obs = obs.OBS()
Config(obs.APIURL, 'openSUSE:Factory')
self.api = StagingAPI(obs.APIURL, 'openSUSE:Factory')
def test_accept_comments(self):
c_api = CommentAPI(self.api.apiurl)
staging_c = 'openSUSE:Factory:Staging:C'
comments = c_api.get_comments(project_name=staging_c)
# Accept staging C (containing apparmor and mariadb)
self.assertEqual(True, AcceptCommand(self.api).perform(staging_c))
# Comments are cleared up
accepted_comments = c_api.get_comments(project_name=staging_c)
self.assertNotEqual(len(comments), 0)
self.assertEqual(len(accepted_comments), 0)
# But the comment was written at some point
self.assertEqual(len(self.obs.comment_bodies), 1)
comment = self.obs.comment_bodies[0]
self.assertTrue('The following packages have been submitted to openSUSE:Factory' in comment)
self.assertTrue('apparmor' in comment)
self.assertTrue('mariadb' in comment)