Exemplo n.º 1
0
  def test_info_command(self):
    config = Configuration()
    options = Mock()
    file_mock = common.mock_file_object('FOO=bar\n')

    with patch('sys.stdout', new_callable=StringIO.StringIO) as stdout:
      with patch('__builtin__.open', Mock(return_value=file_mock), create=True):
        webports.__main__.cmd_info(config, options, ['foo'])
        self.assertRegexpMatches(stdout.getvalue(), "FOO=bar")
Exemplo n.º 2
0
    def test_info_command(self):
        config = Configuration()
        options = Mock()
        file_mock = common.mock_file_object('FOO=bar\n')

        with patch('sys.stdout', new_callable=io.StringIO) as stdout:
            with patch('__builtin__.open',
                       Mock(return_value=file_mock),
                       create=True):
                webports.__main__.cmd_info(config, options, ['foo'])
                self.assertRegex(stdout.getvalue(), "FOO=bar")
Exemplo n.º 3
0
 def test_write_stamp(self, mock_get_info):
   fake_binary_pkg_info = textwrap.dedent('''\
     NAME=foo
     VERSION=1.0
     BUILD_CONFIG=release
     BUILD_ARCH=arm
     BUILD_TOOLCHAIN=glibc
     BUILD_SDK_VERSION=38
     BUILD_NACLPORTS_REVISION=1414
     ''')
   mock_get_info.return_value = fake_binary_pkg_info
   pkg = binary_package.BinaryPackage('foo')
   mock_stamp_file = common.mock_file_object()
   with patch('__builtin__.open', Mock(return_value=mock_stamp_file),
              create=True):
     pkg.write_stamp()
   mock_stamp_file.write.assert_called_once_with(fake_binary_pkg_info)
Exemplo n.º 4
0
def create_mock_installed_package():
  file_mock = common.mock_file_object(test_info)
  with patch('__builtin__.open', Mock(return_value=file_mock), create=True):
    return installed_package.InstalledPackage('dummy_file')
Exemplo n.º 5
0
def create_mock_installed_package():
    file_mock = common.mock_file_object(test_info)
    with patch('__builtin__.open', Mock(return_value=file_mock), create=True):
        return installed_package.InstalledPackage('dummy_file')
Exemplo n.º 6
0
 def test_install_file(self, makedirs_mock, rename_mock):
   mock_file = common.mock_file_object()
   with patch('__builtin__.open', Mock(return_value=mock_file)):
     binary_package.install_file('fname', 'location1', 'location2')
     makedirs_mock.assert_called_once_with('location2')
     rename_mock.assert_has_calls([call('location1/fname', 'location2/fname')])