Example #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)
Example #2
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
Example #3
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'
Example #4
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
Example #5
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()
Example #6
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)
Example #8
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)
Example #9
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)