def _CheckFileDifference(self, scenario_name): file_internal = test_util.TestResourceFilename( os.path.join('diff_codebases', 'codebase_internal', scenario_name)) file_public = test_util.TestResourceFilename( os.path.join('diff_codebases', 'codebase_public', scenario_name)) file_diff_obj = base.AreFilesDifferent( file_internal, file_public, relative_filename=scenario_name, record_full_diffs=True) print 'file_diff_obj for scenario %s: %s' % (scenario_name, file_diff_obj) expected_diff = open(test_util.TestResourceFilename( os.path.join('diff_codebases', scenario_name + '_diff'))).read() self.assertEquals(expected_diff.strip(), file_diff_obj.reason.strip())
def testIntermediateTask(self): basetest.CaptureTestStdout() t = self._ui.BeginIntermediateTask('foo', 'Fooing') with t: self._ui.Info('Bar') basetest.DiffTestStdout( test_util.TestResourceFilename('moe_ui/intermediate.txt'))
def testImmediateTask(self): basetest.CaptureTestStdout() t = self._ui.BeginImmediateTask('foo', 'Fooing') with t: pass basetest.DiffTestStdout( test_util.TestResourceFilename('moe_ui/immediate.txt'))
def testCodebaseDifference(self): codebase_internal = test_util.TestResourceFilename( os.path.join('diff_codebases', 'codebase_internal/')) codebase_public = test_util.TestResourceFilename( os.path.join('diff_codebases', 'codebase_public/')) codebase_diff_obj = base.AreCodebasesDifferent( codebase_utils.Codebase(codebase_internal), codebase_utils.Codebase(codebase_public), record_full_diffs=True) print 'codebase_diff_obj:', codebase_diff_obj expected_diff = open(test_util.TestResourceFilename( os.path.join('diff_codebases', 'codebase_diff'))).read() self.assertEquals(expected_diff.strip(), str(codebase_diff_obj).strip())
def testNestedTasks(self): basetest.CaptureTestStdout() t = self._ui.BeginIntermediateTask('foo', 'Fooing') with t: self._ui.Info('Bar') t2 = self._ui.BeginImmediateTask('baz', 'Bazing') with t2: pass basetest.DiffTestStdout( test_util.TestResourceFilename('moe_ui/nested.txt'))
def testCheckConfig(self): test_util.MockOutDatabase() test_util.MockOutMakeRepositoryConfig() FLAGS.project_config_file = test_util.TestResourceFilename( # We use the same project config as push_codebase_smoke_test os.path.join('push_codebase_smoke_test', 'project_config.txt')) check_config_cmd = simple_commands.CheckConfigCmd( 'check_config', FLAGS) check_config_cmd.Run([])
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()
def RunScenario(self, config_file_name, codebase_expectation): # Mock out test_util.MockOutDatabase() test_util.MockOutMakeRepositoryConfig() FLAGS.project_config_file = test_util.TestResourceFilename( # We use the same project config as push_codebase_smoke_test os.path.join('push_codebase_smoke_test', config_file_name)) CREATE.Run([]) self.assertEqual([codebase_expectation], test_util.CREATED_CODEBASES) test_util.CREATED_CODEBASES = []
def RunScenario(self, config_file_name, codebase_expectations, editor_expectations): # Mock out test_util.MockOutDatabase() test_util.MockOutMakeRepositoryConfig() FLAGS.project_config_file = test_util.TestResourceFilename( os.path.join('push_codebase_smoke_test', config_file_name)) test_util.MockOutPusher(self, codebase_expectations, editor_expectations) push_codebase.main([])
def testSimple(self): FLAGS.internal_revision = '1001' test_util.MockOutDatabase() test_util.MockOutMakeRepositoryConfig() FLAGS.project_config_file = test_util.TestResourceFilename( os.path.join('init_codebases', 'project_config.txt')) test_util.MockOutPusher(self, ('test_internal', '1001'), ('test_public', 'head')) init_codebases.raw_input = lambda s: 'y' init_codebases.getpass.getpass = lambda s: 'fake_password' init_codebases.main([])
def testSpecifyAnEquivalence(self): test_util.MockOutDatabase() test_util.MockOutMakeRepositoryConfig( repository_configs={ 'test_internal': (None, test_util.StaticCodebaseCreator( {'1001': 'simple_python'})), 'test_public': ( None, test_util.StaticCodebaseCreator({'1': 'simple_python'})) }) FLAGS.internal_revision = '1001' FLAGS.public_revision = '1' FLAGS.project_config_file = test_util.TestResourceFilename( os.path.join('init_codebases', 'project_config.txt')) init_codebases.main([])
def setUp(): global SCENARIOS_DIR SCENARIOS_DIR = test_util.TestResourceFilename('git_scenarios/') global UNRUN_SCENARIOS UNRUN_SCENARIOS = set(os.listdir(SCENARIOS_DIR))
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()
import os import sys import gflags as flags from google.apputils import basetest from moe import base from moe import codebase_utils from moe import moe_app from moe.scrubber import scrubber import test_util FLAGS = flags.FLAGS SCENARIOS_DIR = test_util.TestResourceFilename('regtest_scenarios/') UNRUN_SCENARIOS = None def setUp(): # pylint: disable-msg=W0603 global UNRUN_SCENARIOS UNRUN_SCENARIOS = set(os.listdir(SCENARIOS_DIR)) moe_app.InitForTest() def tearDown(): # TODO(dbentley): I can't call assert in global tear down. if UNRUN_SCENARIOS: print 'UNRUN_SCENARIOS:', repr(UNRUN_SCENARIOS) sys.exit(1)
def testNonExistentButCreate(self): self.AllowPost() FLAGS.project_config_file = test_util.TestResourceFilename( 'db_client/bar_project_config.txt') self.assertSucceeds(create_project=True)
from google.apputils import file_util import gflags as flags from google.apputils import basetest from moe import config_utils from moe.scrubber import base from moe.scrubber import comment_scrubber from moe.scrubber import scrubber as scrubber_module from moe.scrubber import sensitive_string_scrubber import test_util from moe.scrubber import usernames from moe.scrubber import whitelist FLAGS = flags.FLAGS TEST_DATA_DIR = test_util.TestResourceFilename('comment_scrubber_test/') class FakeContext(object): def __init__(self): self.errors = [] def AddError(self, error): self.errors.append(error) def TestCommentExtractor(test_case, extractor, source_file, expected_file): comments = extractor.ExtractComments( test_util.FakeFile(filename=source_file)) expected_text = file_util.Read(expected_file) expected_json = simplejson.loads(expected_text)