コード例 #1
0
ファイル: test_package.py プロジェクト: devyanikota/pkgdb2
    def test_pkg_retired_everywhere(self):
        """ Test the retired_everywhere property of Package. """
        create_retired_pkgs(self.session)

        packages = model.Package.search(
            session=self.session, pkg_name='guake', limit=1)
        self.assertFalse(packages[0].retired_everywhere)

        packages = model.Package.search(
            session=self.session, pkg_name='fedocal', limit=1)
        self.assertTrue(packages[0].retired_everywhere)
コード例 #2
0
    def test_api_retired_filled(self):
        """ Test the api_retired function with a filled database. """
        create_retired_pkgs(self.session)

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

        expected = "# Number of packages: 1\n# collection: Fedora\nfedocal"
        self.assertEqual(output.data, expected)

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

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

        expected = {
            'collection': 'Fedora',
            "total_packages": 1,
            "packages": [
                "fedocal",
            ],
        }

        self.assertDictEqual(data, expected)

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

        self.assertEqual(data, expected)

        output = self.app.get('/api/retired/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = "# Number of packages: 1\n"\
        "# collection: Fedora EPEL\nguake"
        self.assertEqual(output.data, expected)
コード例 #3
0
    def test_api_retired_filled(self):
        """ Test the api_retired function with a filled database. """
        create_retired_pkgs(self.session)

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

        expected = "# Number of packages: 1\n# collection: Fedora\nfedocal"
        self.assertEqual(output.data, expected)

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

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

        expected = {
            'collection': 'Fedora',
            "total_packages": 1,
            "packages": [
                "fedocal",
            ],
        }

        self.assertDictEqual(data, expected)

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

        self.assertEqual(data, expected)

        output = self.app.get('/api/retired/?collection=Fedora EPEL')
        self.assertEqual(output.status_code, 200)

        expected = "# Number of packages: 1\n"\
        "# collection: Fedora EPEL\nguake"
        self.assertEqual(output.data, expected)