예제 #1
0
 def setUp(self):
     self._dl = download.BaseDownloader()
     # filesystem
     self.filesystem = fake_filesystem.FakeFilesystem()
     self.filesystem.CreateFile(r'C:\input.ini', contents=_TEST_INI)
     download.os = fake_filesystem.FakeOsModule(self.filesystem)
     download.open = fake_filesystem.FakeFileOpen(self.filesystem)
예제 #2
0
  def setUp(self):

    self.buildinfo = buildinfo.BuildInfo()
    # filesystem
    self.filesystem = fake_filesystem.FakeFilesystem()
    self.cb = builder.ConfigBuilder(self.buildinfo)
    self.cb._task_list = []
예제 #3
0
 def setUp(self):
     self.cache = cache.Cache()
     fakefs = fake_filesystem.FakeFilesystem()
     fakefs.CreateDirectory(r'C:\Directory')
     os_module = fake_filesystem.FakeOsModule(fakefs)
     self.mock_open = fake_filesystem.FakeFileOpen(fakefs)
     cache.os = os_module
     cache.open = self.mock_open
예제 #4
0
 def setUp(self):
     self.buildinfo = buildinfo.BuildInfo()
     # filesystem
     self.filesystem = fake_filesystem.FakeFilesystem()
     runner.os = fake_filesystem.FakeOsModule(self.filesystem)
     runner.open = fake_filesystem.FakeFileOpen(self.filesystem)
     runner.shutil = fake_filesystem_shutil.FakeShutilModule(
         self.filesystem)
     self.cr = runner.ConfigRunner(self.buildinfo)
     self.cr._task_list_path = '/tmp/task_list.yaml'
예제 #5
0
 def setUp(self):
     # fake filesystem
     fakefs = fake_filesystem.FakeFilesystem()
     fakefs.CreateDirectory(r'/stage')
     fakefs.CreateFile(r'/file1.txt', contents='file1')
     fakefs.CreateFile(r'/file2.txt', contents='file2')
     self.fake_open = fake_filesystem.FakeFileOpen(fakefs)
     file_system.os = fake_filesystem.FakeOsModule(fakefs)
     file_system.shutil = fake_filesystem_shutil.FakeShutilModule(fakefs)
     file_system.open = self.fake_open
     self.fakefs = fakefs
예제 #6
0
 def setUp(self):
     # fake filesystem
     self.filesystem = fake_filesystem.FakeFilesystem()
     self.filesystem.CreateDirectory('/dev')
     buildinfo.os = fake_filesystem.FakeOsModule(self.filesystem)
     buildinfo.open = fake_filesystem.FakeFileOpen(self.filesystem)
     # setup
     mock_wmi = mock.patch.object(buildinfo.hw_info.wmi_query,
                                  'WMIQuery',
                                  autospec=True)
     self.addCleanup(mock_wmi.stop)
     mock_wmi.start()
     self.buildinfo = buildinfo.BuildInfo()
예제 #7
0
    def setUp(self, unused_tk):
        self.ui = chooser.Chooser(_TEST_CONF, preload=False)
        v1 = mock.Mock()
        v1.Value.return_value = 'value1'
        v2 = mock.Mock()
        v2.Value.return_value = 'value2'
        v3 = mock.Mock()
        v3.Value.return_value = 'value3'
        self.ui.fields = {'field1': v1, 'field2': v2, 'field3': v3}

        self.fs = fake_filesystem.FakeFilesystem()
        chooser.resources.os = fake_filesystem.FakeOsModule(self.fs)
        self.fs.CreateFile('/resources/logo.gif')
예제 #8
0
 def testSetupTaskList(self):
     cache = autobuild.constants.SYS_CACHE
     filesystem = fake_filesystem.FakeFilesystem()
     filesystem.CreateFile(r'X:\task_list.yaml')
     autobuild.os = fake_filesystem.FakeOsModule(filesystem)
     self.assertEqual(self.autobuild._SetupTaskList(),
                      '%s\\task_list.yaml' % cache)
     autobuild.FLAGS.preserve_tasks = True
     self.assertEqual(self.autobuild._SetupTaskList(),
                      '%s\\task_list.yaml' % cache)
     autobuild.FLAGS.environment = 'WinPE'
     self.assertEqual(self.autobuild._SetupTaskList(), r'X:\task_list.yaml')
     self.assertTrue(autobuild.os.path.exists(r'X:\task_list.yaml'))
     autobuild.FLAGS.preserve_tasks = False
     self.assertEqual(self.autobuild._SetupTaskList(), r'X:\task_list.yaml')
     self.assertFalse(autobuild.os.path.exists(r'X:\task_list.yaml'))
예제 #9
0
 def testBuildInfoSave(self, build_info, reg):
   fs = fake_filesystem.FakeFilesystem()
   installer.open = fake_filesystem.FakeFileOpen(fs)
   installer.os = fake_filesystem.FakeOsModule(fs)
   fs.CreateFile(
       '/tmp/build_info.yaml',
       contents='{BUILD: {opt 1: true, opt 2: some value, opt 3: 12345}}\n')
   build_info.Cache.return_value.Path.return_value = '/tmp'
   s = installer.BuildInfoSave(None, build_info)
   s.Run()
   reg.return_value.SetKeyValue.assert_has_calls(
       [
           mock.call(installer.constants.REG_ROOT, 'opt 1', True),
           mock.call(installer.constants.REG_ROOT, 'opt 2', 'some value'),
           mock.call(installer.constants.REG_ROOT, 'opt 3', 12345),
       ],
       any_order=True)
   s.Run()
  def test_load_hl7v2_from_gcs_success_output_file_content(
      self, mock_blob, mock_client):
    with self.shell.builtin_trap:
      fs = fake_filesystem.FakeFilesystem()
      fake_open = fake_filesystem.FakeFileOpen(fs)
      mock_blob.download_as_string.return_value = self.sample_hl7v2
      mock_blob.content_encoding = None
      mock_client.return_value.bucket.return_value.get_blob.return_value = mock_blob
      ip = self.shell.get_ipython()
      failure = ip.magics_manager.register(wstl.LoadHL7Magics)
      self.assertIsNone(failure)

      with mock.patch.multiple(wstl, open=fake_open):
        tmp_filename = "fake.txt"
        ip.run_line_magic(
            "load_hl7v2_gcs", """--bucket_name=foo
          --source_blob_name=bar --dest_file_name={}""".format(tmp_filename))
        self.assertEqual(
            fs.GetObject(tmp_filename).contents.decode("UTF-8"),
            self.sample_hl7v2)
예제 #11
0
 def setUp(self):
   self.fs = fake_filesystem.FakeFilesystem()
   powershell.os = fake_filesystem.FakeOsModule(self.fs)
   powershell.resources.os = fake_filesystem.FakeOsModule(self.fs)
   self.fs.CreateFile('/resources/bin/script.ps1')
   self.ps = powershell.PowerShell()
예제 #12
0
 def setUp(self):
     self.filesystem = fake_filesystem.FakeFilesystem()
     files.open = fake_filesystem.FakeFileOpen(self.filesystem)
     files.file_util.shutil = fake_filesystem_shutil.FakeShutilModule(
         self.filesystem)
예제 #13
0
 def setUp(self):
     self.filesystem = fake_filesystem.FakeFilesystem()
     files.open = fake_filesystem.FakeFileOpen(self.filesystem)
     files.file_util.os = fake_filesystem.FakeOsModule(self.filesystem)
예제 #14
0
 def setUp(self):
     self.fs = fake_filesystem.FakeFilesystem()
     resources.os = fake_filesystem.FakeOsModule(self.fs)
     self.fs.CreateFile('/test/file.txt')