# This file is part of fedmsg.
# Copyright (C) 2014 Red Hat, Inc.
#
# fedmsg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# fedmsg is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with fedmsg; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Authors: Michael Simacek <msimacek@redhat.com>
#
""" Tests for Koschei messages """

import unittest

from fedmsg_meta_fedora_infrastructure.tests.base import Base

from common import add_doc


class TestKoscheiPackageStateChange(Base):
    """ Koschei is a continuous integration system for RPM packages. It tracks
        dependency changes done in Koji repositories and rebuilds packages whose
        build dependencies change too much.

    This message type is published by Koschei when a package was added and build
    fine.
    """

    expected_title = "koschei.package.state.change"
    expected_subti = "rnv's builds started to fail after build task 1234"
    expected_link = 'http://koschei.cloud.fedoraproject.org/package/rnv'
    expected_packages = set(['rnv'])

    msg = {
        "username": "msimacek",
        "i": 2,
        "timestamp": 1412260063,
        "msg_id": "2014-45d99116-f93e-45ef-8611-04fa2eabbb82",
        "topic": "org.fedoraproject.dev.koschei.package.state.change",
        "msg": {
            "name": "rnv",
            "old": "ok",
            "new": "failing",
            "build_task_id": 1234,
            "repo_id": 5678,
            "koji_instance": "primary",
            "watched_tag": "f22-build"
        }
    }

@@ -1270,46 +1270,55 @@
 hen 
-a 
 package
- was added and build%0A    fine
+'s build or resolution%0A    state changes
 .%0A  

Fix out-of-sync docstring