def setUp(self):
     ConfigureFakeFetchers(os.path.join(sys.path[0], os.pardir))
     self._base_path = os.path.join(sys.path[0], 'test_data',
                                    'github_file_system')
     self._file_system = GithubFileSystem(
         AppEngineUrlFetcher(url_constants.GITHUB_URL),
         AppEngineBlobstore())
Beispiel #2
0
 def Render(self, path, headers=None, servlet=RenderServlet):
     '''Renders |path|, returning a tuple of (status, contents, headers).
 '''
     headers = headers or {}
     # TODO(kalman): do this via a LocalFileSystem not this fake AppEngine stuff.
     ConfigureFakeFetchers(os.path.join(self._base_dir, 'docs'))
     url_path = urlparse.urlparse(path.replace(os.sep, '/')).path
     return servlet(Request(url_path, headers)).Get()
Beispiel #3
0
 def Render(self, path, headers={}, always_online=False):
     '''Renders |path|, returning a tuple of (status, contents, headers).
 '''
     # TODO(kalman): do this via a LocalFileSystem not this fake AppEngine stuff.
     ConfigureFakeFetchers(os.path.join(self._base_dir, 'docs'))
     handler_was_always_online = Handler.ALWAYS_ONLINE
     Handler.ALWAYS_ONLINE = always_online
     try:
         response = _Response()
         url_path = urlparse.urlparse(path.replace(os.sep, '/')).path
         Handler(_Request(url_path, headers), response).get()
         content = response.out.getvalue()
         if isinstance(content, unicode):
             content = content.encode('utf-8', 'replace')
         return (content, response.status, response.headers)
     finally:
         Handler.ALWAYS_ONLINE = handler_was_always_online
Beispiel #4
0
 def setUp(self):
     ConfigureFakeFetchers()
     self._base_path = os.path.join(sys.path[0], 'test_data',
                                    'github_file_system')
     self._file_system = GithubFileSystem.CreateChromeAppsSamples(
         ObjectStoreCreator.ForTest())
Beispiel #5
0
 def setUp(self):
     ConfigureFakeFetchers()
  parser.add_option('-t', '--type', default="apps",
      help='Type of API to generate (apps or extensions). Defaults to "apps"')
  parser.add_option('-c', '--channel', default="trunk",
      help='Name of the chromium channel (trunk, dev, beta or stable). Defaults to "trunk"')

  (opts, argv) = parser.parse_args()

  if (not os.path.isdir(opts.directory) or
      not os.path.isdir(os.path.join(opts.directory, 'docs')) or
      not os.path.isdir(os.path.join(opts.directory, 'api'))):
    sys.stderr.write('Directory does not exist or does not contain extension '
          'docs. Please, use -h option to get help on command line options.\n')
    exit()

  sys.path.append(os.path.join(opts.directory, "docs", "server2"))

  from fake_fetchers import ConfigureFakeFetchers
  from file_system import FileNotFoundError
  import compiled_file_system as compiled_fs

  local_path = opts.directory
  ConfigureFakeFetchers(os.path.join(local_path, DOCS_PATH))

  import handler

  channel_name = opts.channel
  handler._CleanBranches()
  inst = handler._GetInstanceForBranch(channel_name, local_path)
  
  print(GenerateAPI(inst, opts.type))
 def setUp(self):
     ConfigureFakeFetchers()
     self._patcher = RietveldPatcher(
         EXTENSIONS_PATH, '14096030',
         AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER))
Beispiel #8
0
        '-t',
        '--time',
        action='store_true',
        help='Print the time taken rendering rather than the result.')

    (opts, argv) = parser.parse_args()

    if (not os.path.isdir(opts.directory)
            or not os.path.isdir(os.path.join(opts.directory, 'docs'))
            or not os.path.isdir(os.path.join(opts.directory, 'api'))):
        print(
            'Specified directory does not exist or does not contain extension '
            'docs.')
        exit()

    ConfigureFakeFetchers(os.path.join(opts.directory, 'docs'))
    from handler import Handler

    if opts.render:
        if opts.render.find('#') >= 0:
            (path, iterations) = opts.render.rsplit('#', 1)
            extra_iterations = int(iterations) - 1
        else:
            path = opts.render
            extra_iterations = 0

        if opts.time:
            start_time = time.time()

        content, status, headers = _Render(path)
        if status in [301, 302]:
 def setUp(self):
     ConfigureFakeFetchers()
     self._patcher = RietveldPatcher(
         '14096030', CreateUrlFetcher(url_constants.CODEREVIEW_SERVER))
import os
import sys
from StringIO import StringIO
import re
import unittest

# Run build_server so that files needed by tests are copied to the local
# third_party directory.
import build_server
build_server.main()

BASE_PATH = None
EXPLICIT_TEST_FILES = None

from fake_fetchers import ConfigureFakeFetchers
ConfigureFakeFetchers(os.path.join(sys.path[0], os.pardir))

# Import Handler later because it immediately makes a request to github. We need
# the fake urlfetch to be in place first.
from handler import Handler

class _MockResponse(object):
  def __init__(self):
    self.status = 200
    self.out = StringIO()
    self.headers = {}

  def set_status(self, status):
    self.status = status

class _MockRequest(object):