python类main()的实例源码

test_help_function_of_sqlite.py 文件源码 项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def testHelpMessageForSQLitePlugin(self):
    """test the --help option for SQLite"""
    helper = end_to_end_test_helper.EndToEndTestHelper('not needed',
                                                       'not needed')

    if platform.system() in ['Linux']:
      message_help = (
          'Usage: main.py sqlite [OPTIONS]\r\n\r\n'
          'Options:\r\n  '
          '--path TEXT       The path to plaso\r\n  '
          '--name TEXT       The plugin name\r\n  '
          '--testfile TEXT   The testfile path\r\n  '
          '--sql / --no-sql  The output example flag for the SQL Query for the '
          'plugin.\r\n  '
          '--help            Show this message and exit.')

      command = 'python {0} sqlite --help'.format(helper.MAIN_PATH)
      child = pexpect.spawn(command)
      child.expect_exact(message_help)
    else:
      raise NotImplementedError("test only implemented for linux platform")
test_ui_base.py 文件源码 项目:PyWallet 作者: AndreMiras 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def helper_test_dismiss_dialog_twice(self, app):
        """
        If by some choice the dismiss event of a dialog created with
        Controller.create_dialog_helper() is fired twice, it should be
        handled gracefully, refs #89.
        """
        Controller = main.Controller
        title = "title"
        body = "body"
        # makes sure the controller has no dialog
        self.assertEqual(Controller.dialogs, [])
        # creates one and verifies it was created
        dialog = Controller.create_dialog_helper(title, body)
        self.assertEqual(len(Controller.dialogs), 1)
        # dimisses it once and verifies it was handled
        dialog.dispatch('on_dismiss')
        self.assertEqual(Controller.dialogs, [])
        # then a second time and it should not crash
        dialog.dispatch('on_dismiss')
        self.assertEqual(Controller.dialogs, [])
test_help_function.py 文件源码 项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def testHelpMessage(self):
    """test the universal --help Option"""
    helper = end_to_end_test_helper.EndToEndTestHelper('not needed',
                                                       'not needed')

    if platform.system() in ['Linux']:
      message_help = ('Usage: main.py [OPTIONS] COMMAND [ARGS]...\r\n\r\n'
                      'Options:\r\n'
                      '  --help  Show this message and exit.\r\n\r\n'
                      'Commands:\r\n'
                      '  sqlite')
      command = 'python {0} --help'.format(helper.MAIN_PATH)
      child = pexpect.spawn(command)
      child.expect_exact(message_help)
    else:
      raise NotImplementedError("test only implemented for linux platform")
test_main.py 文件源码 项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def testSQLiteHelp(self):
    """testing the main of the sqlite"""
    runner = CliRunner()
    result = runner.invoke(main.entry_point, ['sqlite', '--help'])
    expected_output = ('Usage: entry_point sqlite [OPTIONS]\n'
                       '\n'
                       'Options:\n'
                       '  --path TEXT       The path to plaso\n'
                       '  --name TEXT       The plugin name\n'
                       '  --testfile TEXT   The testfile path\n'
                       '  --sql / --no-sql  The output example flag for the '
                       'SQL Query for the plugin.\n'
                       '  --help            Show this message and exit.\n')

    self.assertEqual(expected_output, str(result.output))
    self.assertEqual(0, result.exit_code)
fastevent_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def todo_test_pump(self):

        # __doc__ (as of 2008-08-02) for pygame.fastevent.pump:

          # pygame.fastevent.pump() -> None
          # update the internal messages
          # 
          # For each frame of your game, you will need to make some sort
          # of call to the event queue. This ensures your program can internally
          # interact with the rest of the operating system. If you are not using
          # other event functions in your game, you should call pump() to allow
          # pygame to handle internal actions.
          # 
          # There are important things that must be dealt with internally in the
          # event queue. The main window may need to be repainted. Certain joysticks
          # must be polled for their values. If you fail to make a call to the event
          # queue for too long, the system may decide your program has locked up.

        self.fail()
test.py 文件源码 项目:Flask_Blog 作者: sugarguo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def run_tests(self):
        import unittest

        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False):
            module = self.test_args[-1].split('.')[0]
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                list(map(sys.modules.__delitem__, del_modules))

        loader_ep = EntryPoint.parse("x="+self.test_loader)
        loader_class = loader_ep.load(require=False)
        cks = loader_class()
        unittest.main(
            None, None, [unittest.__file__]+self.test_args,
            testLoader = cks
        )
recipe-578161.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def transition_function(P):
    """
    The main principle on building the transition function is to think about
    the fact that every time we scan a new character from the input sequence
    the suffix should match with the prefix of the pattern. If that is not
    possible for every length of the suffix, the next state need to be the
    initial, otherwise the length of the suffix that matches properly will be
    exactly the next state.
    """
    alphabet = st.ascii_letters+st.punctuation+st.digits+st.whitespace
    m = len(P)
    trans = [{c:0 for c in alphabet} for i in range(m)]
    for s in range(m):
        for c in alphabet:
            k = min(m, s+1)
            while (P[:s]+c)[-k:] != P[:k]:
                k-=1

            trans[s][c]=k

    return trans
client_api_test.py 文件源码 项目:TACTIC-Handler 作者: listyque 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def _test_checkin_with_handoff(my):

        search_type = "unittest/person"
        code = "joe"
        search_key = my.server.build_search_key(search_type, code)

        # copy file to handoff dir
        path = "%s/test/miso_ramen.jpg" % my.client_lib_dir
        handoff_dir = my.server.get_handoff_dir()
        shutil.copy(path, handoff_dir)

        # check the file in
        snapshot = my.server.simple_checkin(search_key, "publish", path, use_handoff_dir=True)
        snapshot_code = snapshot.get("code")

        # get the filename
        file_type = "main"
        path = my.server.get_path_from_snapshot(snapshot_code, file_type)
        exists = os.path.exists(path)
        my.assertEquals(True, exists)

        # check that the file name is correct
        filename = os.path.basename(path)
        # changed naming.. adds "publish"
        my.assertEquals("miso_ramen_publish_v001.jpg", filename)
test_program.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def testCatchBreakInstallsHandler(self):
        module = sys.modules['unittest.main']
        original = module.installHandler
        def restore():
            module.installHandler = original
        self.addCleanup(restore)

        self.installed = False
        def fakeInstallHandler():
            self.installed = True
        module.installHandler = fakeInstallHandler

        program = self.program
        program.catchbreak = True

        program.testRunner = FakeRunner

        program.runTests()
        self.assertTrue(self.installed)
test_validate.py 文件源码 项目:maggma 作者: materialsproject 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_violations(self):
        "Test error determination in CollectionValidator.why_bad"
        obj = vv.Validator()
        # main & where clause, both fail
        q = vv.MongoQuery()
        q.add_clause(vv.MongoClause(vv.Constraint('foo', 'size>', 2)))
        q.add_clause(vv.MongoClause(vv.Constraint('bar', '>', 1)))
        rec = {'foo': [0], 'bar': 0}
        reasons = obj._get_violations(q, rec)
        self.failUnlessEqual(len(reasons), 2)
        for r in reasons:
            if r.field == 'bar':
                self.failUnless(r.op == '>' and r.got_value == 0 and r.expected_value == 1)
        # all pass
        q = vv.MongoQuery()
        q.add_clause(vv.MongoClause(vv.Constraint('foo', 'size>', 2)))
        q.add_clause(vv.MongoClause(vv.Constraint('bar', '>', 1)))
        rec = {'foo': [0, 1, 2], 'bar': 9}
        reasons = obj._get_violations(q, rec)
        rtuples = [r.as_tuple() for r in reasons]
        print('\n'.join(map(str, rtuples)))
        self.failUnlessEqual(len(reasons), 0)
generatejson_test.py 文件源码 项目:cloud-vision 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_one_detection(self):
        input_file = StringIO(self.image_name + ' 1:1')
        output_filename = os.path.join(self.temp_dir, 'empty_file.json')
        main(input_file, output_filename)
        self.assertTrue(os.path.exists(output_filename))
        with open(output_filename, 'r') as output_file:
            obj = json.load(output_file)
        self.assertEqual(1, len(obj['requests']))
        self.assertIn('image', obj['requests'][0])
        self.assertIn('content', obj['requests'][0]['image'])
        self.assertIn('features', obj['requests'][0])
        self.assertEqual(1, len(obj['requests'][0]['features']))
        self.assertEqual(
            'FACE_DETECTION', obj['requests'][0]['features'][0]['type'])
        self.assertEqual(
            1, obj['requests'][0]['features'][0]['maxResults'])
generatejson_test.py 文件源码 项目:cloud-vision 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_multiple_detections(self):
        input_file = StringIO(self.image_name + ' 1:1 2:3')
        output_filename = os.path.join(self.temp_dir, 'empty_file.json')
        main(input_file, output_filename)
        self.assertTrue(os.path.exists(output_filename))
        with open(output_filename, 'r') as output_file:
            obj = json.load(output_file)
        self.assertEqual(1, len(obj['requests']))
        self.assertIn('image', obj['requests'][0])
        self.assertIn('content', obj['requests'][0]['image'])
        self.assertIn('features', obj['requests'][0])
        self.assertEqual(2, len(obj['requests'][0]['features']))
        self.assertEqual(
            'FACE_DETECTION', obj['requests'][0]['features'][0]['type'])
        self.assertEqual(
            1, obj['requests'][0]['features'][0]['maxResults'])
        self.assertEqual(
            'LANDMARK_DETECTION', obj['requests'][0]['features'][1]['type'])
        self.assertEqual(
            3, obj['requests'][0]['features'][1]['maxResults'])
generatejson_test.py 文件源码 项目:cloud-vision 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_bad_detection_type(self):
        input_file = StringIO(self.image_name + ' 125:1')
        output_filename = os.path.join(self.temp_dir, 'empty_file.json')
        main(input_file, output_filename)
        self.assertTrue(os.path.exists(output_filename))
        with open(output_filename, 'r') as output_file:
            obj = json.load(output_file)
        self.assertEqual(1, len(obj['requests']))
        self.assertIn('image', obj['requests'][0])
        self.assertIn('content', obj['requests'][0]['image'])
        self.assertIn('features', obj['requests'][0])
        self.assertEqual(1, len(obj['requests'][0]['features']))
        self.assertEqual(
            'TYPE_UNSPECIFIED', obj['requests'][0]['features'][0]['type'])
        self.assertEqual(
            1, obj['requests'][0]['features'][0]['maxResults'])
test_c_parser.py 文件源码 项目:SwiftKitten 作者: johncsnyder 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_expressions(self):
        e1 = '''int k = (r + 10.0) >> 6 + 8 << (3 & 0x14);'''
        self.assert_all_Constants(e1, ['10.0', '6', '8', '3', '0x14'])

        e2 = r'''char n = '\n', *prefix = "st_";'''
        self.assert_all_Constants(e2, [r"'\n'", '"st_"'])

        s1 = r'''int main() {
                    int i = 5, j = 6, k = 1;
                    if ((i=j && k == 1) || k > j)
                        printf("Hello, world\n");
                    return 0;
                 }'''
        ps1 = self.parse(s1)
        self.assert_all_Constants(ps1,
            ['5', '6', '1', '1', '"Hello, world\\n"', '0'])
        self.assert_num_ID_refs(ps1, 'i', 1)
        self.assert_num_ID_refs(ps1, 'j', 2)
test_c_generator.py 文件源码 项目:SwiftKitten 作者: johncsnyder 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_switchcase(self):
        self._assert_ctoc_correct(r'''
        int main() {
            switch (myvar) {
            case 10:
            {
                k = 10;
                p = k + 1;
                break;
            }
            case 20:
            case 30:
                return 20;
            default:
                break;
            }
        }
        ''')
blurb.py 文件源码 项目:core-workflow 作者: python 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test(*args):
    """
Run unit tests.  Only works inside source repo, not when installed.
    """
    # unittest.main doesn't work because this isn't a module
    # so we'll do it ourselves

    print("-" * 79)

    for clsname, cls in sorted(globals().items()):
        if clsname.startswith("Test") and isinstance(cls, type):
            o = cls()
            for fnname in sorted(dir(o)):
                if fnname.startswith("test"):
                    fn = getattr(o, fnname)
                    if callable(fn):
                        fn()
    print()
    print(tests_run, "tests passed.")
caterpillar_test.py 文件源码 项目:caterpillar 作者: chromium 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def setUp(self):
    """Stores a BeautifulSoup in self.soup."""
    html = """
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8"/>
  <title>
   Héllø World
  </title>
  <link href="styles/main.css" rel="stylesheet"/>
  <meta content="Hello World" name="name"/>
 </head>
 <body>
  <h1>
   Hello, Wo®ld!
  </h1>
 </body>
</html>"""
    self.soup = bs4.BeautifulSoup(html)
caterpillar_test.py 文件源码 项目:caterpillar 作者: chromium 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setUp(self):
    """Stores a BeautifulSoup in self.soup."""
    html = """
<!DOCTYPE html>
<html>
 <head>
  <title>
   Hello Wó®ld
  </title>
  <link href="styles/main.css" rel="stylesheet"/>
 </head>
 <body>
  <h1>
   Héllo, World! ÚÑÍ¢ÓÐÉ
  </h1>
 </body>
</html>"""
    self.soup = bs4.BeautifulSoup(html)
caterpillar_test.py 文件源码 项目:caterpillar 作者: chromium 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_no_duplicate_metas(self):
    """Tests that existing meta tags aren't duplicated."""
    chrome_app_manifest = {'description': 'a déscription'}
    root_path = 'path'
    html = """
<!DOCTYPE html>
<html>
 <head>
  <title>
   Hello Wó®ld
  </title>
  <meta name="description" content="tést description"/>
  <link href="styles/main.css" rel="stylesheet"/>
 </head>
 <body>
  <h1>
   Héllo, World! ÚÑÍ¢ÓÐÉ
  </h1>
 </body>
</html>"""
    soup = bs4.BeautifulSoup(html)
    caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
    metas = soup.findAll('meta', {'name': 'description'})
    self.assertEqual(len(metas), 1)
    self.assertEqual(metas[0]['content'], 'tést description')
test_prot_query.py 文件源码 项目:psp 作者: cmap 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_main(self):

        out_dir = "clue/functional_tests/527ef1c3"

        # Delete out_dir if it exists already
        if os.path.exists(out_dir):
            shutil.rmtree(out_dir)

        config_path = "https://s3.amazonaws.com/data.clue.io/psp/examples/example_user_input.yml"
        second_config_path = "clue/functional_tests/test_prot_query_alt_psp_on_clue.yml"
        args_string = "-u {} -o {} -p {}".format(
            config_path, out_dir, second_config_path).split()
        args = prot_query.build_parser().parse_args(args_string)
        prot_query.main(args)

        self.assertTrue(os.path.exists(os.path.join(out_dir, "INTROSPECT_CONN.gct")))
        self.assertTrue(os.path.exists(os.path.join(out_dir, "CONCATED_CONN.gct")))
        self.assertTrue(os.path.exists(os.path.join(out_dir, "success.txt")))

        # Alt config file only specified 2 cell lines (excludes YAPC)
        self.assertFalse(os.path.exists(os.path.join(out_dir, "YAPC_CONN.gct")))

        # Clean up
        shutil.rmtree(out_dir)
test_introspect.py 文件源码 项目:psp 作者: cmap 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_main1(self):
        input_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                      "test_introspect_main.gct")
        output_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                       "test_introspect_main_out.gct")
        expected_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                         "test_introspect_main_expected.gct")

        args_string = "-i {} -o {} -fa chd1".format(input_gct_path, output_gct_path)
        args = introspect.build_parser().parse_args(args_string.split())

        introspect.main(args)

        # Read in output and expected gcts and confirm that they're equal
        output_gct = parse(output_gct_path)
        expected_gct = parse(expected_gct_path)

        pd.util.testing.assert_almost_equal(expected_gct.data_df, output_gct.data_df, check_less_precise=2)
        pd.testing.assert_frame_equal(expected_gct.row_metadata_df, output_gct.row_metadata_df)
        pd.testing.assert_frame_equal(expected_gct.col_metadata_df, output_gct.col_metadata_df)

        # Clean up
        os.remove(output_gct_path)
test_introspect.py 文件源码 项目:psp 作者: cmap 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_main2(self):
        input_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                      "test_introspect_main.gct")
        output_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                       "test_introspect_main_out2.gct")
        expected_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR,
                                         "test_introspect_main_expected2.gct")

        args_string = "-i {} -o {} -fa moa".format(input_gct_path, output_gct_path)
        args = introspect.build_parser().parse_args(args_string.split())

        introspect.main(args)

        # Read in output and expected gcts and confirm that they're equal
        output_gct = parse(output_gct_path)
        expected_gct = parse(expected_gct_path)

        pd.util.testing.assert_almost_equal(expected_gct.data_df, output_gct.data_df, check_less_precise=True)
        pd.util.testing.assert_frame_equal(expected_gct.row_metadata_df, output_gct.row_metadata_df)
        pd.util.testing.assert_frame_equal(expected_gct.col_metadata_df, output_gct.col_metadata_df)

        # Clean up
        os.remove(output_gct_path)
test_annotate_gct_from_mapping.py 文件源码 项目:psp 作者: cmap 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_main(self):
        gct_path = os.path.join(functional_tests_dir, "test_annotate_gct_from_mapping_in.gct")
        mapping_path = os.path.join(functional_tests_dir, "test_annotate_gct_from_mapping.tsv")
        expected_gct_path = os.path.join(functional_tests_dir, "test_annotate_gct_from_mapping_expected.gct")
        out_path = os.path.join(functional_tests_dir, "test_annotate_gct_from_mapping_out.gct")

        args_string = "-i {} -m {} -o {} -f {}".format(
            gct_path, mapping_path, out_path, "pert_iname")
        args = agfm.build_parser().parse_args(args_string.split())

        agfm.main(args)

        # Read in expected and actual outputs
        e_gct = parse(expected_gct_path)
        out_gct = parse(out_path)

        pd.util.testing.assert_frame_equal(e_gct.data_df, out_gct.data_df)
        pd.util.testing.assert_frame_equal(e_gct.row_metadata_df, out_gct.row_metadata_df)
        pd.util.testing.assert_frame_equal(e_gct.col_metadata_df, out_gct.col_metadata_df)

        # Clean up
        os.remove(out_path)
test_tear.py 文件源码 项目:psp 作者: cmap 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_main(self):
        in_gct_path = os.path.join(FUNCTIONAL_TESTS_DIR, "test_tear_main.gct")
        out_name = os.path.join(FUNCTIONAL_TESTS_DIR, "test_tear_out.gct")

        args_string = ("-i {} -o {} -dm -p {}").format(
            in_gct_path, out_name, "psp_production.cfg")
        args = tear.build_parser().parse_args(args_string.split())
        tear.main(args)

        # Read in result
        out_gct = parse(out_name)

        e_values = np.array(
            [[0., 4.07, -1.48, -10.71, 0.],
            [4.43, -3.26, -0.23, 0., 1.48],
            [0., 2.49, 2.50, -1.48, -0.86]])
        self.assertTrue(np.allclose(e_values, out_gct.data_df, atol=1e-2))

        # Clean up
        os.remove(out_name)
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def testDownload(self):
    self.SetUpWorkdir(populate_bucket=True)

    with _MockedInput('y'):
      status = update.main([
          'download',
          '--dry-run',
          '--bucket', self.paths.bucket,
          '--config', self.paths.config_file,
          '--sdk-root', self.paths.gms.sdk_root,
      ])

    self.assertEqual(status, 0, 'the command should have succeeded.')

    # sdk_root should contain zip contents, zip sha1, license
    self.assertTrue(os.path.isfile(self.paths.gms.client_paths[0]))
    self.assertTrue(os.path.isfile(self.paths.gms.lib_zip_sha1))
    self.assertTrue(os.path.isfile(self.paths.gms.license))
    self.assertEquals(_GetFileContent(self.paths.gms.license),
                      self.DEFAULT_LICENSE)
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def testDownloadBot(self):
    self.SetUpWorkdir(populate_bucket=True, bot_env=True)

    # No need to type 'y' on bots
    status = update.main([
        'download',
        '--dry-run',
        '--bucket', self.paths.bucket,
        '--config', self.paths.config_file,
        '--sdk-root', self.paths.gms.sdk_root,
    ])

    self.assertEqual(status, 0, 'the command should have succeeded.')

    # sdk_root should contain zip contents, zip sha1, license
    self.assertTrue(os.path.isfile(self.paths.gms.client_paths[0]))
    self.assertTrue(os.path.isfile(self.paths.gms.lib_zip_sha1))
    self.assertTrue(os.path.isfile(self.paths.gms.license))
    self.assertEquals(_GetFileContent(self.paths.gms.license),
                      self.DEFAULT_LICENSE)
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def testDownloadAlreadyUpToDate(self):
    self.SetUpWorkdir(
        populate_bucket=True,
        existing_zip_sha1=self.DEFAULT_ZIP_SHA1)

    status = update.main([
        'download',
        '--dry-run',
        '--bucket', self.paths.bucket,
        '--config', self.paths.config_file,
        '--sdk-root', self.paths.gms.sdk_root,
    ])

    self.assertEqual(status, 0, 'the command should have succeeded.')

    # there should not be new files downloaded to sdk_root
    self.assertFalse(os.path.isfile(os.path.join(self.paths.gms.client_paths[0],
                                                 'dummy_file')))
    self.assertFalse(os.path.isfile(self.paths.gms.license))
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def testDownloadAcceptedLicense(self):
    self.SetUpWorkdir(
        populate_bucket=True,
        existing_license=self.DEFAULT_LICENSE)

    # License already accepted, no need to type
    status = update.main([
        'download',
        '--dry-run',
        '--bucket', self.paths.bucket,
        '--config', self.paths.config_file,
        '--sdk-root', self.paths.gms.sdk_root,
    ])

    self.assertEqual(status, 0, 'the command should have succeeded.')

    # sdk_root should contain zip contents, zip sha1, license
    self.assertTrue(os.path.isfile(self.paths.gms.client_paths[0]))
    self.assertTrue(os.path.isfile(self.paths.gms.lib_zip_sha1))
    self.assertTrue(os.path.isfile(self.paths.gms.license))
    self.assertEquals(_GetFileContent(self.paths.gms.license),
                      self.DEFAULT_LICENSE)
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def testDownloadRefusedLicense(self):
    self.SetUpWorkdir(
        populate_bucket=True,
        existing_license='Old license')

    with _MockedInput('n'):
      status = update.main([
          'download',
          '--dry-run',
          '--bucket', self.paths.bucket,
          '--config', self.paths.config_file,
          '--sdk-root', self.paths.gms.sdk_root,
      ])

    self.assertEqual(status, 0, 'the command should have succeeded.')

    # there should not be new files downloaded to sdk_root
    self.assertFalse(os.path.isfile(os.path.join(self.paths.gms.client_paths[0],
                                                 'dummy_file')))
    self.assertEquals(_GetFileContent(self.paths.gms.license),
                      'Old license')
update_test.py 文件源码 项目:nojs 作者: chrisdickinson 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def testDownloadNoAndroidSDK(self):
    self.SetUpWorkdir(
        populate_bucket=True,
        existing_license='Old license')

    non_existing_sdk_root = os.path.join(self.workdir, 'non_existing_sdk_root')
    # Should not run, no typing needed
    status = update.main([
        'download',
        '--dry-run',
        '--bucket', self.paths.bucket,
        '--config', self.paths.config_file,
        '--sdk-root', non_existing_sdk_root,
    ])

    self.assertEqual(status, 0, 'the command should have succeeded.')
    self.assertFalse(os.path.isdir(non_existing_sdk_root))


问题


面经


文章

微信
公众号

扫码关注公众号