openSUSE-release-tools/tests/accept_tests.py

48 lines
1.5 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (C) 2014 tchvatal@suse.cz, openSUSE.org
# Distribute under GPLv2 or later
import sys
import unittest
import httpretty
import mock
from obs import APIURL
from obs import OBS
from osc import oscerr
from osclib.accept_command import AcceptCommand
from oscs import StagingAPI
from osclib.comments import CommentAPI
class TestAccept(unittest.TestCase):
def setUp(self):
"""
Initialize the configuration
"""
self.obs = OBS()
self.api = StagingAPI(APIURL)
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)
with mock.patch('oscs.StagingAPI.find_openqa_state', return_value='Nothing'):
2014-06-16 17:39:46 +02:00
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 factory' in comment)
self.assertTrue('apparmor' in comment)
self.assertTrue('mariadb' in comment)