示例#1
0
 def test_index_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(path="/", method="GET", headers=[("Accept", "application/json")]):
         response = app.dispatch_request()
         self.assertEqual(
             json.loads(response.data),
             {
                 "distro_packages": '[["openSUSE", 1285]]',
                 "vendors": [{"vendor_name": "openSUSE", "vendor_url": "openSUSE"}],
                 "distros": [
                     {
                         "distro_name": "openSUSE",
                         "systems": [
                             {
                                 "sys_hwuuid": SYS_HWUUID,
                                 "arch": "x86_64",
                                 "distro_version": "12.1",
                                 "distro_name": "openSUSE",
                             }
                         ],
                         "distro_version": "12.1",
                     }
                 ],
             },
         )
         self.assertEqual(response.headers["Content-Type"], "application/json")
示例#2
0
 def test_package_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(path='/package/sed/4.2.1/5.1.2/x86_64',
             method='GET', headers=[('Accept', 'application/json')]):
         response = app.dispatch_request()
         self.assertEqual(json.loads(response.data), {
             "packages": [{
                 "sys_hwuuid": "677ec7c2-3b9e-4b25-8f45-b651d8bbb701",
                 "sub_date": today.strftime("%Y-%m-%d"),
                 "pkg_status": "voted",
                 "pkg_name": "sed",
                 "pkg_version": "4.2.1",
                 "pkg_arch": "x86_64",
                 "vendor_name": "openSUSE",
                 "pkg_epoch": "",
                 "pkg_release": "5.1.2"
               }],
             "voted": 1,
             "generic_package": {
                 "sys_hwuuid": "677ec7c2-3b9e-4b25-8f45-b651d8bbb701",
                 "sub_date": today.strftime("%Y-%m-%d"),
                 "pkg_status": "voted",
                 "pkg_name": "sed",
                 "pkg_version": "4.2.1",
                 "pkg_arch": "x86_64",
                 "vendor_name": "openSUSE",
                 "pkg_epoch": "",
                 "pkg_release": "5.1.2"
             }
         })
         self.assertEqual(response.headers['Content-Type'],
                          'application/json')
示例#3
0
 def test_index_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(
         path='/', method='GET', headers=[('Accept', 'application/json')]):
         response = app.dispatch_request()
         self.assertEqual(json.loads(response.data), {
             "distro_packages": "[[\"openSUSE\", 1285]]",
             "vendors": [{
                 "vendor_name": "openSUSE",
                 "vendor_url": "openSUSE"
                     }],
             "distros": [{
                 "distro_name": "openSUSE",
                 "systems": [{
                     "sys_hwuuid":
                         "677ec7c2-3b9e-4b25-8f45-b651d8bbb701",
                         "arch": "x86_64",
                         "distro_version": "12.1",
                         "distro_name": "openSUSE"
                         }],
                     "distro_version": "12.1"
                 }]
             })
         self.assertEqual(response.headers['Content-Type'],
                          'application/json')
示例#4
0
 def test_vendor_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(path="/vendor/openSUSE", method="GET", headers=[("Accept", "application/json")]):
         response = app.dispatch_request()
         self.assertEqual(
             json.loads(response.data), {"vendor": {"vendor_name": "openSUSE", "vendor_url": "openSUSE"}}
         )
         self.assertEqual(response.headers["Content-Type"], "application/json")
示例#5
0
 def test_vendor_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(
         path='/vendor/openSUSE', method='GET',
         headers=[('Accept', 'application/json')]):
         response = app.dispatch_request()
         self.assertEqual(json.loads(response.data), {
                 "vendor": {
                     "vendor_name": "openSUSE",
                     "vendor_url": "openSUSE"
                     }})
         self.assertEqual(response.headers['Content-Type'],
                          'application/json')
示例#6
0
 def test_system_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(
         path="/system/%s" % SYS_HWUUID, method="GET", headers=[("Accept", "application/json")]
     ):
         response = app.dispatch_request()
         self.assertEqual(
             json.loads(response.data),
             {
                 "system": {
                     "arch": "x86_64",
                     "sys_hwuuid": SYS_HWUUID,
                     "submissions": [
                         {"sub_date": today.strftime("%Y-%m-%d"), "sys_hwuuid": SYS_HWUUID, "popcorn_version": "0.1"}
                     ],
                     "distro_name": "openSUSE",
                     "distro_version": "12.1",
                 }
             },
         )
         self.assertEqual(response.headers["Content-Type"], "application/json")
示例#7
0
 def test_system_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(
             path='/system/677ec7c2-3b9e-4b25-8f45-b651d8bbb701',
             method='GET', headers=[('Accept', 'application/json')]):
         response = app.dispatch_request()
         self.assertEqual(json.loads(response.data), {
             "system": {
                 "arch": "x86_64",
                 "sys_hwuuid":
                     "677ec7c2-3b9e-4b25-8f45-b651d8bbb701",
                 "submissions": [{
                     "sub_date": today.strftime("%Y-%m-%d"),
                     "sys_hwuuid":
                         "677ec7c2-3b9e-4b25-8f45-b651d8bbb701",
                     "popcorn_version": "0.1"
                     }],
                 "distro_name": "openSUSE",
                 "distro_version": "12.1"
                 }
             })
         self.assertEqual(response.headers['Content-Type'],
                          'application/json')
示例#8
0
 def test_package_json(self):
     self.submit(compress=False, header=False)
     with app.test_request_context(
         path="/package/sed/4.2.1/5.1.2/x86_64", method="GET", headers=[("Accept", "application/json")]
     ):
         response = app.dispatch_request()
         self.assertEqual(
             json.loads(response.data),
             {
                 "packages": [
                     {
                         "sys_hwuuid": SYS_HWUUID,
                         "sub_date": today.strftime("%Y-%m-%d"),
                         "pkg_status": "voted",
                         "pkg_name": "sed",
                         "pkg_version": "4.2.1",
                         "pkg_arch": "x86_64",
                         "vendor_name": "openSUSE",
                         "pkg_epoch": "",
                         "pkg_release": "5.1.2",
                     }
                 ],
                 "voted": 1,
                 "generic_package": {
                     "sys_hwuuid": SYS_HWUUID,
                     "sub_date": today.strftime("%Y-%m-%d"),
                     "pkg_status": "voted",
                     "pkg_name": "sed",
                     "pkg_version": "4.2.1",
                     "pkg_arch": "x86_64",
                     "vendor_name": "openSUSE",
                     "pkg_epoch": "",
                     "pkg_release": "5.1.2",
                 },
             },
         )
         self.assertEqual(response.headers["Content-Type"], "application/json")