def test_read_config(self):
     # Empty.
     put_config('')
     self.assertEqual('', importer.read_config())
     # Good.
     put_config('tarball{}')
     self.assertEqual('tarball{}', importer.read_config())
示例#2
0
 def test_read_config(self):
     # Empty.
     put_config('', '')
     self.assertEqual('', importer.read_config())
     # Good.
     put_config('tarball{}', '')
     self.assertEqual('tarball{}', importer.read_config())
     # Legacy.
     put_config('', '[{"url":"12"}]')
     self.assertEqual('tarball {\n  url: "12"\n}\n', importer.read_config())
示例#3
0
 def test_read_config(self):
   # Empty.
   put_config('', '')
   self.assertEqual('', importer.read_config())
   # Good.
   put_config('tarball{}', '')
   self.assertEqual('tarball{}', importer.read_config())
   # Legacy.
   put_config('', '[{"url":"12"}]')
   self.assertEqual('tarball {\n  url: "12"\n}\n', importer.read_config())
示例#4
0
 def test_importer_config_post_bad(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual({'text': 'Invalid config format.'}, response.json)
   self.assertEqual([], importer.read_config())
示例#5
0
 def test_importer_config_post_ok(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=200)
   self.assertEqual({'ok': True}, response.json)
   self.assertEqual(GOOD_IMPORTER_CONFIG, importer.read_config())
 def test_importer_config_post_bad(self):
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual(
       {'text': '"url" field is required in TarballEntry'}, response.json)
   self.assertEqual('', importer.read_config())
 def test_importer_config_post_ok(self):
   self.mock_admin()
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': GOOD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=200)
   self.assertEqual({'ok': True}, response.json)
   self.assertEqual(GOOD_IMPORTER_CONFIG, importer.read_config())
示例#8
0
 def test_importer_config_post_bad(self):
     response = self.app.post_json(
         '/auth_service/api/v1/importer/config',
         {'config': BAD_IMPORTER_CONFIG},
         headers={
             'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()
         },
         status=400)
     self.assertEqual({'text': 'Invalid config format.'}, response.json)
     self.assertEqual([], importer.read_config())
 def test_importer_config_post_bad(self):
   self.mock_admin()
   response = self.app.post_json(
       '/auth_service/api/v1/importer/config',
       {'config': BAD_IMPORTER_CONFIG},
       headers={'X-XSRF-Token': auth_testing.generate_xsrf_token_for_test()},
       status=400)
   self.assertEqual(
       {'text': '"url" field is required in TarballEntry'}, response.json)
   self.assertEqual('', importer.read_config())
示例#10
0
 def get(self):
   self.send_response({'config': importer.read_config()})
 def get(self):
     self.send_response({'config': importer.read_config()})
示例#12
0
def _update_imports_config(rev, conf):
    """Applies imports.cfg config."""
    # Rewrite existing config even if it is the same (to update 'rev').
    cur = importer.read_config()
    importer.write_config(conf, {'rev': rev.revision, 'url': rev.url})
    return cur != conf
示例#13
0
文件: config.py 项目: rmistry/luci-py
def _update_imports_config(rev, conf):
  """Applies imports.cfg config."""
  # Rewrite existing config even if it is the same (to update 'rev').
  cur = importer.read_config()
  importer.write_config(conf, {'rev': rev.revision, 'url': rev.url})
  return cur != conf