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
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
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)
def install_manifest(): return Manifest('/test_dir/manifest.yaml', manifest_contents=dict( version='0.1.0', name='ship_it', method='install', ))
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
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'
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
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'
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
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
def manifest(): return Manifest('/test_dir/manifest.yaml', manifest_contents=dict( version='0.1.0', name='ship_it', ))
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
def manifest_with_no_version(self, manifest_path): return Manifest(manifest_path, manifest_contents=dict(name='ship_it'))