예제 #1
0
def test_manifest_normalizes_path(mock_content, path):
    """
    Test that the resulting manifest has the path it came from
    """
    assert not mock_content.called
    _man = Manifest(path)
    mock_content.assert_called_once_with(Manifest.normalize_path(path))
    assert _man.path
    assert os.path.isabs(_man.path)
    assert _man.manifest_dir
    assert os.path.isabs(_man.manifest_dir)
    assert '~' not in _man.path
    assert '~' not in _man.manifest_dir
예제 #2
0
def test_upgrade_wheel(val, expected):
    """
    Test that upgrade wheel is available
    """
    test_man = Manifest('manifest.yaml',
                        manifest_contents=dict(upgrade_wheel=val))
    assert test_man.upgrade_wheel is expected
예제 #3
0
def test_open_for_yaml(mock_fobj, mock_load):
    assert not mock_fobj.called
    assert not mock_load.called
    Manifest('some path')
    mock_fobj.assert_called_once_with(os.path.abspath('some path'))
    mock_load.assert_called_once_with(mock_fobj.return_value,
                                      Loader=yaml.BaseLoader)
예제 #4
0
def install_manifest():
    return Manifest('/test_dir/manifest.yaml',
                    manifest_contents=dict(
                        version='0.1.0',
                        name='ship_it',
                        method='install',
                    ))
예제 #5
0
def get_manifest_with_no_version(manifest_path):

    no_version = Manifest(manifest_path,
                          manifest_contents=dict(name='ship_it'))

    with mock.patch('ship_it.validate_path'),\
         mock.patch('ship_it.get_manifest_from_path',
                    return_value=no_version) as mocked:
        yield mocked
예제 #6
0
 def test_default_to_virtualenv_name(self):
     """
     Test that if unspecified, it uses the virtualenv name and /opt
     """
     test_man = Manifest('/path/manifest.yaml',
                         manifest_contents=dict(name='prefix-ship_it',
                                                virtualenv_name='ship_it'))
     assert test_man.virtualenv_name == 'ship_it'
     assert test_man.remote_package_path == '/opt'
     assert test_man.remote_virtualenv_path == '/opt/ship_it'
예제 #7
0
    def test_override(self, pkg_path, expected):
        """
        Test that if unspecified, it uses the virtualenv name and the manifest
        directory
        """
        test_man = Manifest('/path/manifest.yaml',
                            manifest_contents=dict(
                                name='ship_it', local_package_path=pkg_path))

        assert test_man.local_package_path == expected
예제 #8
0
def test_override_virtualenv_name():
    """
    Test that there's a distinction between name and virtualenv name
    """
    test_man = Manifest('manifest.yaml',
                        manifest_contents=dict(name='prefix-ship_it',
                                               virtualenv_name='ship_it'))
    assert test_man.virtualenv_name == 'ship_it'
    assert test_man.remote_virtualenv_path == '/opt/ship_it'
    assert test_man.name == 'prefix-ship_it'
예제 #9
0
def test_manifest_normalizes_path(mock_content, path):
    """
    Test that the resulting manifest has the path it came from
    """
    assert not mock_content.called
    _man = Manifest(path)
    mock_content.assert_called_once_with(Manifest.normalize_path(path))
    assert _man.path
    assert os.path.isabs(_man.path)
    assert _man.manifest_dir
    assert os.path.isabs(_man.manifest_dir)
    assert "~" not in _man.path
    assert "~" not in _man.manifest_dir
예제 #10
0
def test_manifest_content_from_path(manifest_content, expected_version):
    with mock.patch('ship_it.manifest.Manifest.get_manifest_fobj') as get:
        get.return_value = StringIO(manifest_content)
        manifest_output = Manifest.get_manifest_content_from_path(None)
        assert manifest_output['version'] == expected_version
예제 #11
0
def manifest():
    return Manifest('/test_dir/manifest.yaml',
                    manifest_contents=dict(
                        version='0.1.0',
                        name='ship_it',
                    ))
예제 #12
0
def test_manifest_content_from_path(manifest_content, expected_version):
    with mock.patch("ship_it.manifest.Manifest.get_manifest_fobj") as get:
        get.return_value = StringIO(manifest_content)
        manifest_output = Manifest.get_manifest_content_from_path(None)
        assert manifest_output["version"] == expected_version
예제 #13
0
 def manifest_with_no_version(self, manifest_path):
     return Manifest(manifest_path, manifest_contents=dict(name='ship_it'))