Esempio n. 1
0
def setUp():
    """Set up a database."""
    # pylint: disable-msg=W0603
    moe_app.InitForTest()
    global PROCESS
    env = dict(os.environ)

    executable = None
    for path in APPSERVER_PATHS:
        if not path:
            continue
        path = os.path.expanduser(path)
        if os.access(path, os.X_OK):
            executable = path
            break
    if not executable:
        raise RuntimeError(
            ('No dev_appserver.py found. Install somewhere in %s '
             '(or set environment variable DEV_APPSERVER)') %
            repr(APPSERVER_PATHS))

    db_app_dir = pkg_resources.resource_filename(
        pkg_resources.Requirement.parse('moe'), 'moe/dbapp/')
    # clear datastore on start, for better reproducibility
    args = [executable, '--require_indexes', '--clear_datastore', db_app_dir]
    PROCESS = subprocess.Popen(args, env=env)
    WaitForServer()
Esempio n. 2
0
 def setUp(self):
     FLAGS.Reset()
     moe_app.InitForTest()
     self.stubs = stubout.StubOutForTesting()
     self.stubs.Set(db_client, '_Get', None)
     self.stubs.Set(db_client, '_Post', None)
     self.config_file_path = test_util.TestResourceFilename(
         'db_client/project_config.txt')
     self.name = 'foo'
     db_client.ServerBackedMoeDbClient = MockDbClient
     db_client.GetStoredProject = self._GetStoredProject
     test_util.MockOutMakeRepositoryConfig()
Esempio n. 3
0
def setUp():
    moe_app.InitForTest()
Esempio n. 4
0
def setUp():
  global SCENARIOS_DIR
  SCENARIOS_DIR = test_util.TestResourceFilename('merge_codebases_scenarios/')
  global UNRUN_SCENARIOS
  UNRUN_SCENARIOS = set(os.listdir(SCENARIOS_DIR))
  moe_app.InitForTest()
Esempio n. 5
0
def setUp():
  # pylint: disable-msg=W0603
  global UNRUN_SCENARIOS
  UNRUN_SCENARIOS = set(os.listdir(SCENARIOS_DIR))
  moe_app.InitForTest()
Esempio n. 6
0
        out_file = os.path.join(FLAGS.test_tmpdir, scenario_name + '.out.txt')
        base.WriteUtf8(out_file, output)
        basetest.DiffTestFiles(expected, out_file)

    def testRecurUntilMatchingRevision(self):
        repos = svn.SvnRepository('http://not_a_url', 'ummy svn repository')
        log_file = os.path.join(SCENARIOS_DIR, 'long_log', 'input')
        log_text = file_util.Read(log_file)

        def Revision12(r):
            return r.rev_id == '12'

        self.mox.StubOutWithMock(svn, 'RunSvn')
        svn.RunSvn(
            ['log', '--xml', '-l', '50', '-r', '15:1', 'http://not_a_url'],
            need_stdout=True).AndReturn(log_text)
        self.mox.ReplayAll()
        result = repos.RecurUntilMatchingRevision('15', Revision12)
        self.assertEqual(4, len(result))
        self.assertEqual('12', result[-1].rev_id)
        self.mox.UnsetStubs()


def FilterLog(text):
    return '\n'.join([unicode(rev) for rev in svn.ParseRevisions(text, '')])


if __name__ == '__main__':
    moe_app.InitForTest()
    basetest.main()
Esempio n. 7
0
def setUp():
    FLAGS.Reset()
    moe_app.InitForTest()
    init_codebases.DefineFlags(FLAGS)
Esempio n. 8
0
def setUp():
    global REPO
    moe_app.InitForTest()
    REPO = mercurial.MercurialRepository(EXAMPLE_REPOSITORY_URL, 'test')
Esempio n. 9
0
 def setUp(self):
     FLAGS.Reset()
     moe_app.InitForTest()
Esempio n. 10
0
def setUp():
    FLAGS.Reset()
    moe_app.InitForTest()
    push_codebase.DefineFlags(FLAGS)