bh@242: # Copyright (C) 2009 by Intevation GmbH bh@242: # Authors: bh@242: # Bernhard Herzog bh@242: # bh@242: # This program is free software under the GPL (>=v2) bh@242: # Read the file COPYING coming with the software for details. bh@242: bh@242: bh@242: import sys bh@242: import os bh@242: import unittest bh@242: bh@242: from filesupport import FileTestMixin bh@242: bh@242: from treepkg.run import call, capture_output, SubprocessError bh@242: bh@242: bh@242: class TestListNotifications(unittest.TestCase, FileTestMixin): bh@242: bh@242: treepkg_cfg_template = """\ bh@242: [DEFAULT] bh@242: tracks_dir: %(tracksdir)s bh@242: root_cmd: true bh@242: pbuilderrc: bh@242: deb_email: packager@example.com bh@242: deb_fullname: Sample Packager bh@293: pkg_revision_template: treepkg%%%%(pkg_revision)d bh@242: handle_dependencies: False bh@242: bh@242: [treepkg] bh@242: check_interval: 3600 bh@242: instructions_file: bh@242: bh@242: [pkg_kdepim] bh@242: svn_url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim bh@242: base_dir: %%(tracks_dir)s/kdepim bh@242: packager_class: recipes.kde_enterprise_3_5.kdepim bh@242: """ bh@242: bh@242: track_files = [("kdepim", bh@242: [("pkg", bh@242: [("704195-31", bh@242: [("status", "TreePackagerStatus 0.0\n"), bh@242: ("src", []), bh@242: ("binary", [])]), bh@242: ("702432-47", bh@242: [("status", bh@242: "\n".join(("TreePackagerStatus 0.0", bh@242: "status: error", bh@242: "notification_mail: notification_pending", bh@242: ""))), bh@242: ("src", []), bh@242: ("binary", [])])])])] bh@242: bh@242: def setUp(self): bh@242: self.bindir = os.path.join(os.path.dirname(__file__), bh@242: os.pardir, "bin") bh@242: self.listpendingnotifications \ bh@242: = os.path.join(self.bindir, bh@242: "listpendingnotifications.py") bh@242: self.tracksdir = self.create_files("tracks", self.track_files) bh@242: config = self.treepkg_cfg_template % dict(tracksdir=self.tracksdir) bh@242: self.config_file = self.create_temp_file("treepkg.cfg", config) bh@242: bh@242: def test_listpendingnotifications(self): bh@242: cmd = [sys.executable, self.listpendingnotifications, bh@242: "--config-file=" + self.config_file] bh@242: self.assertEquals(capture_output(cmd), "error kdepim 702432 47\n")