def main(source, dest): dest = os.path.abspath(dest) if not os.path.isfile(source): raise SystemExit("Error: Source (%s) is not a file" % source) if os.path.exists(dest): raise SystemExit("Error: Destination path (%s) already exists" % dest) old_config = manager.read_raw(source) manager.create_new_config(dest, old_config)
def test_create_new_config(self, mock_write, mock_manifest, mock_makedirs): path, master_content = '/bogus/path/', mock.Mock() filename = '/bogus/path/MASTER.yaml' manifest = mock_manifest.return_value manifest.get_file_name.return_value = None manager.create_new_config(path, master_content) mock_makedirs.assert_called_with(path) mock_write.assert_called_with(filename, master_content) manifest.create.assert_called_with() manifest.add.assert_called_with(schema.MASTER_NAMESPACE, filename)
def test_create_new_config(self, mock_write, mock_manifest, mock_makedirs): path, master_content = "/bogus/path/", mock.Mock() filename = "/bogus/path/MASTER.yaml" manifest = mock_manifest.return_value manifest.get_file_name.return_value = None manager.create_new_config(path, master_content) mock_makedirs.assert_called_with(path) mock_write.assert_called_with(filename, master_content) manifest.create.assert_called_with() manifest.add.assert_called_with(schema.MASTER_NAMESPACE, filename)
def save_config(self, config_text): """Save the initial tron configuration.""" manager.create_new_config(self.config_path, config_text)