Пример #1
0
    def test_get_critpath_packages(self):
        """ Test the get_critpath_packages method of PackageListing. """
        create_package_acl(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(pkg_list, [])

        pkg_list = model.PackageListing.get_critpath_packages(self.session,
                                                              branch='master')
        self.assertEqual(pkg_list, [])

        create_package_critpath(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(len(pkg_list), 2)
        self.assertEqual(pkg_list[0].point_of_contact, "kernel-maint")
        self.assertEqual(pkg_list[0].collection.branchname, "f18")
        self.assertEqual(pkg_list[1].point_of_contact, "group::kernel-maint")
        self.assertEqual(pkg_list[1].collection.branchname, "master")

        pkg_list = model.PackageListing.get_critpath_packages(self.session,
                                                              branch='master')
        self.assertEqual(len(pkg_list), 1)
        self.assertEqual(pkg_list[0].point_of_contact, "group::kernel-maint")
        self.assertEqual(pkg_list[0].collection.branchname, "master")
Пример #2
0
    def test_get_critpath_packages(self):
        """ Test the get_critpath_packages method of PackageListing. """
        create_package_acl(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(pkg_list, [])

        pkg_list = model.PackageListing.get_critpath_packages(
            self.session, branch='devel')
        self.assertEqual(pkg_list, [])

        create_package_critpath(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(len(pkg_list), 2)
        self.assertEqual(
            pkg_list[0].point_of_contact, "kernel-maint")
        self.assertEqual(
            pkg_list[0].collection.branchname, "F-18")
        self.assertEqual(
            pkg_list[1].point_of_contact, "group::kernel-maint")
        self.assertEqual(
            pkg_list[1].collection.branchname, "devel")

        pkg_list = model.PackageListing.get_critpath_packages(
            self.session, branch='devel')
        self.assertEqual(len(pkg_list), 1)
        self.assertEqual(
            pkg_list[0].point_of_contact, "group::kernel-maint")
        self.assertEqual(
            pkg_list[0].collection.branchname, "devel")
Пример #3
0
    def test_api_monitored_filled(self):
        """ Test the api_monitored function with a filled database. """
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/monitored/')
        self.assertEqual(output.status_code, 200)

        expected = "# Number of packages: 1\nkernel"
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/monitored/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/monitored/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            "total_packages": 1,
            "packages": [
                "kernel",
            ],
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/monitored/',
                              environ_base={'HTTP_ACCEPT': 'application/json'})
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)
    def test_api_critpath_filled(self):
        """ Test the api_critpath function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/critpath/')
        self.assertEqual(output.status_code, 200)

        expected = """== devel ==
* kernel
== F-18 ==
* kernel
"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/critpath/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/critpath/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'pkgs': {
                u'F-18': [u"kernel"],
                u'devel': [u"kernel"]
            },
        }

        self.assertEqual(data, expected)
Пример #5
0
    def test_api_pendingacls_filled(self):
        """ Test the api_pendingacls function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/pendingacls/')
        self.assertEqual(output.status_code, 200)

        expected = """# Number of requests pending: 2
guake:master has ralph waiting for approveacls
guake:master has toshio waiting for commit"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            'pending_acls': [
                {
                    'acl': 'approveacls',
                    'collection': 'master',
                    'namespace': 'rpms',
                    'package': 'guake',
                    'status': 'Awaiting Review',
                    'user': '******'
                },
                {
                    'acl': 'commit',
                    'collection': 'master',
                    'namespace': 'rpms',
                    'package': 'guake',
                    'status': 'Awaiting Review',
                    'user': '******'
                }
            ],
            'total_requests_pending': 2
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=pingou')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=toshio')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        expected = {'pending_acls': [], 'total_requests_pending': 0}

        self.assertEqual(data, expected)
Пример #6
0
    def test_api_pendingacls_filled(self):
        """ Test the api_pendingacls function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/pendingacls/')
        self.assertEqual(output.status_code, 200)

        expected = """# Number of requests pending: 2
guake:master has ralph waiting for approveacls
guake:master has toshio waiting for commit"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            'pending_acls': [{
                'acl': 'approveacls',
                'collection': 'master',
                'package': 'guake',
                'status': 'Awaiting Review',
                'user': '******'
            }, {
                'acl': 'commit',
                'collection': 'master',
                'package': 'guake',
                'status': 'Awaiting Review',
                'user': '******'
            }],
            'total_requests_pending':
            2
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=pingou')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=toshio')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        expected = {'pending_acls': [], 'total_requests_pending': 0}

        self.assertEqual(data, expected)
Пример #7
0
    def test_api_critpath_filled(self):
        """ Test the api_critpath function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/critpath/')
        self.assertEqual(output.status_code, 200)

        expected = """== master ==
* kernel
== f18 ==
* kernel
"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/critpath/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/critpath/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'pkgs': {
                u'f18': [
                    u"kernel"
                ],
                u'master': [
                    u"kernel"
                ]
            },
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/critpath/?format=json&branches=master')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            u'pkgs': {
                u'master': [
                    u"kernel"
                ]
            },
        }

        self.assertEqual(data, expected)
Пример #8
0
    def test_api_groups_filled(self):
        """ Test the api_groups function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/groups/')
        self.assertEqual(output.status_code, 200)

        expected = """# Number of groups: 2
gtk-sig
kernel-maint"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/groups/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/groups/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            'groups': [
                'gtk-sig',
                'kernel-maint',
            ],
            'total_groups': 2
        }

        self.assertEqual(data, expected)

        output = self.app.get(
            '/api/groups/',
            environ_base={'HTTP_ACCEPT': 'application/json'})
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)
Пример #9
0
    def test_api_groups_filled(self):
        """ Test the api_groups function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/groups/')
        self.assertEqual(output.status_code, 200)

        expected = """# Number of groups: 2
gtk-sig
kernel-maint"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/groups/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/groups/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            'groups': [
                'gtk-sig',
                'kernel-maint',
            ],
            'total_groups': 2
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/groups/',
                              environ_base={'HTTP_ACCEPT': 'application/json'})
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)
Пример #10
0
    def test_api_koschei_filled(self):
        """ Test the api_koschei function with a filled database. """
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/koschei/')
        self.assertEqual(output.status_code, 200)

        expected = "# Number of packages: 1\nkernel"
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/koschei/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/koschei/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            "total_packages": 1,
            "packages": [
                "kernel",
            ],
        }


        self.assertEqual(data, expected)

        output = self.app.get(
            '/api/koschei/',
            environ_base={'HTTP_ACCEPT': 'application/json'})
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)
Пример #11
0
    def test_api_package_list(self):
        """ Test the api_package_list function.  """

        output = self.app.get('/api/packages/guake/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "error": "No packages found for these parameters",
                "packages": [],
                "output": "notok",
                "page_total": 1,
                "page": 1,
            }
        )

        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/packages/guake/')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 1)
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(
            data['packages'][0]['name'], 'guake')
        self.assertEqual(
            data['packages'][0]['status'], 'Approved')
        self.assertEqual(
            data['packages'][0]['summary'], 'Top down terminal for GNOME')

        output = self.app.get('/api/packages/g*/')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(len(data['packages']), 2)

        output = self.app.get('/api/packages/g*/?count=True')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "ok",
                "packages": 2,
                "page": 1,
                "page_total": 1,
            }
        )

        output = self.app.get('/api/packages/g*/?limit=abc')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 2)
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(
            data['packages'][0]['name'], 'geany')
        self.assertEqual(
            data['packages'][0]['status'], 'Approved')
        self.assertEqual(
            data['packages'][1]['name'], 'guake')
        self.assertEqual(
            data['packages'][1]['status'], 'Approved')

        output = self.app.get('/api/packages/g*/?limit=5000')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 2)
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(
            data['packages'][0]['name'], 'geany')
        self.assertEqual(
            data['packages'][0]['status'], 'Approved')
        self.assertEqual(
            data['packages'][1]['name'], 'guake')
        self.assertEqual(
            data['packages'][1]['status'], 'Approved')

        output = self.app.get('/api/packages/g*/?critpath=1')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['error', 'output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 0)
        self.assertEqual(data['output'], 'notok')

        output = self.app.get('/api/packages/k*/?critpath=1')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 1)
        self.assertEqual(data['packages'][0]['name'], 'kernel')
        self.assertEqual(data['output'], 'ok')

        output = self.app.get('/api/packages/g*/?critpath=0')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(len(data['packages']), 2)
        self.assertEqual(data['output'], 'ok')

        output = self.app.get('/api/packages/g*/?page=abc')
        self.assertEqual(output.status_code, 500)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['error', 'output', 'page', 'page_total'])
        self.assertEqual(data['error'], 'Wrong page provided')
        self.assertEqual(data['output'], 'notok')

        output = self.app.get('/api/packages/g*/?orphaned=False')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['output', 'packages', 'page', 'page_total'])
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(len(data['packages']), 2)
        self.assertEqual(data['packages'][0]['name'], 'geany')
        self.assertEqual(data['packages'][1]['name'], 'guake')

        output = self.app.get('/api/packages/g*/?orphaned=True')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            sorted(data.keys()),
            ['error', 'output', 'packages', 'page', 'page_total'])
        self.assertEqual(
            data['error'], 'No packages found for these parameters')
        self.assertEqual(data['output'], 'notok')
        self.assertEqual(data['packages'], [])
Пример #12
0
    def test_api_package_edit(self, login_func, mock_func):
        """ Test the api_package_edit function.  """
        login_func.return_value = None

        # Redirect as you are not admin
        user = FakeFasUser()

        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/edit/')
            self.assertEqual(output.status_code, 302)

        user = FakeFasUserAdmin()

        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/edit/')
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['error', 'error_detail', 'output']
            )
            self.assertEqual(
                data['error'], "Invalid input submitted")

            self.assertEqual(
                data['output'], "notok")

            self.assertEqual(
                sorted(data['error_detail']),
                [
                    "pkgname: This field is required.",
                ]
            )

        data = {
            'pkgname': 'gnome-terminal',
            'summary': 'Terminal emulator for GNOME',
            'description': 'Terminal for GNOME...',
            'review_url': 'http://bugzilla.redhat.com/1234',
            'status': 'Approved',
            'upstream_url': 'http://www.gnome.org/',
        }
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/edit/', data=data)
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    "error": "No package of this name found",
                    "output": "notok"
                }
            )

        create_package_acl(self.session)
        create_package_critpath(self.session)

        # Before edit:
        output = self.app.get('/api/package/guake/', data=data)
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            data['packages'][0]['package']['upstream_url'],
            'http://guake.org'
        )

        data = {
            'pkgname': 'guake',
            'upstream_url': 'http://www.guake.org',
        }

        # User is not an admin
        user = FakeFasUser()
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/edit/', data=data)
            self.assertEqual(output.status_code, 302)

        # User is an admin
        user = FakeFasUserAdmin()
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/edit/', data=data)
            self.assertEqual(output.status_code, 200)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    "messages": ['Package "guake" edited'],
                    "output": "ok"
                }
            )

        # After edit:
        output = self.app.get('/api/package/guake/', data=data)
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            data['packages'][0]['package']['upstream_url'],
            'http://www.guake.org'
        )
Пример #13
0
    def test_api_package_critpath(self, login_func, mock_func):
        """ Test the api_package_critpath function.  """
        login_func.return_value = None

        # Redirect as you are not admin
        user = FakeFasUser()

        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/')
            self.assertEqual(output.status_code, 302)

        user = FakeFasUserAdmin()

        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/')
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['error', 'error_detail', 'output']
            )
            self.assertEqual(
                data['error'], "Invalid input submitted")

            self.assertEqual(
                data['output'], "notok")

            self.assertEqual(
                sorted(data['error_detail']),
                [
                    'branches: This field is required.',
                    'pkgnames: This field is required.'
                ]
            )

        data = {
            'pkgnames': 'gnome-terminal',
            'branches': 'master'
        }
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/', data=data)
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    "error": "No package found by this name",
                    "output": "notok"
                }
            )

        create_package_acl(self.session)
        create_package_critpath(self.session)

        # Before edit:
        output = self.app.get('/api/package/guake/', data=data)
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        for pkg in data['packages']:
            self.assertFalse(pkg['critpath'])
            self.assertFalse(pkg['critpath'])

        data = {
            'pkgnames': 'guake',
            'branches': ['master', 'f18'],
        }

        # User is an admin - But not updating the critpath
        user = FakeFasUserAdmin()
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/', data=data)
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    "error": "Nothing to update",
                    "output": "notok"
                }
            )

        data = {
            'pkgnames': 'guake',
            'branches': ['foobar'],
        }

        # User is an admin - But not invalid collection the critpath
        user = FakeFasUserAdmin()
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/', data=data)
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    "error": "No collection found by the name of foobar",
                    "output": "notok"
                }
            )

        data = {
            'pkgnames': 'guake',
            'branches': ['master', 'f18'],
            'critpath': True,
        }

        # User is an admin and updating the critpath
        user = FakeFasUserAdmin()
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/critpath/', data=data)
            self.assertEqual(output.status_code, 200)
            data = json.loads(output.data)
            self.assertEqual(
                data,
                {
                    'messages': [
                        'guake: critpath updated on master to True',
                        'guake: critpath updated on f18 to True'
                    ],
                    'output': 'ok'
                }
            )

        # After edit:
        output = self.app.get('/api/package/guake/', data=data)
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        for pkg in data['packages']:
            self.assertTrue(pkg['critpath'])
            self.assertTrue(pkg['critpath'])
Пример #14
0
    def test_api_monitor_package(self, login_func, mock_func):
        """ Test the api_package_critpath function.  """
        login_func.return_value = None

        user = FakeFasUser()

        # No package
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/guake/monitor/1')
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['error', 'output']
            )
            self.assertEqual(
                data['error'], "No package found by this name")

            self.assertEqual(
                data['output'], "notok")

        create_package_acl(self.session)
        create_package_critpath(self.session)

        # User is not a packager
        user.username = '******'
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/guake/monitor/1')
            self.assertEqual(output.status_code, 500)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['error', 'output']
            )
            self.assertEqual(
                data['error'],
                "You are not allowed to update the monitor flag on this "
                "package")

            self.assertEqual(
                data['output'], "notok")

        # Works
        user.username = '******'
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/guake/monitor/1')
            self.assertEqual(output.status_code, 200)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['messages', 'output']
            )
            self.assertEqual(
                data['messages'], "Monitoring status of guake set to True")

            self.assertEqual(
                data['output'], "ok")

            output = self.app.post('/api/package/guake/monitor/1')
            self.assertEqual(output.status_code, 200)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['messages', 'output']
            )
            self.assertEqual(
                data['messages'], "Monitoring status un-changed")

            self.assertEqual(
                data['output'], "ok")

        # User is not a packager but is admin
        user = FakeFasUserAdmin()
        user.username = '******'
        with user_set(pkgdb2.APP, user):
            output = self.app.post('/api/package/guake/monitor/False')
            self.assertEqual(output.status_code, 200)
            data = json.loads(output.data)
            self.assertEqual(
                sorted(data),
                ['messages', 'output']
            )
            self.assertEqual(
                data['messages'], "Monitoring status of guake set to False")

            self.assertEqual(
                data['output'], "ok")