Skip to content

Commit

Permalink
Merge branch 'master' into feature/continuation-file-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Glick authored Nov 30, 2020
2 parents b0e4056 + b107c0e commit fe1d735
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cumulusci/salesforce_api/package_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def from_zipfile(cls, zf, *, options=None, logger=None):
def _convert_sfdx_format(self, path, name):
orig_path = path
with contextlib.ExitStack() as stack:
if not pathlib.Path(path, "package.xml").exists():
# convert sfdx -> mdapi format if path exists but does not have package.xml
if len(os.listdir(path)) and not pathlib.Path(path, "package.xml").exists():
self.logger.info("Converting from sfdx to mdapi format")
path = stack.enter_context(temporary_dir(chdir=False))
args = ["-r", str(orig_path), "-d", path]
Expand Down
9 changes: 9 additions & 0 deletions cumulusci/salesforce_api/tests/test_package_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,21 @@ def test_include_file(self):

def test_convert_sfdx(self):
with temporary_dir() as path:
touch("README.md") # make sure there's something in the directory
with mock.patch("cumulusci.salesforce_api.package_zip.sfdx") as sfdx:
builder = MetadataPackageZipBuilder()
with builder._convert_sfdx_format(path, "Test Package"):
pass
sfdx.assert_called_once()

def test_convert_sfdx__skipped_if_directory_empty(self):
with temporary_dir() as path:
with mock.patch("cumulusci.salesforce_api.package_zip.sfdx") as sfdx:
builder = MetadataPackageZipBuilder()
with builder._convert_sfdx_format(path, "Test Package"):
pass
sfdx.assert_not_called()

def test_removes_feature_parameters_from_unlocked_package(self):
with temporary_dir() as path:
pathlib.Path(path, "package.xml").write_text(
Expand Down
13 changes: 10 additions & 3 deletions cumulusci/tasks/salesforce/Deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def _get_api(self, path=None):
path = self.options.get("path")

package_zip = self._get_package_zip(path)
self.logger.info("Payload size: {} bytes".format(len(package_zip)))
if package_zip is not None:
self.logger.info("Payload size: {} bytes".format(len(package_zip)))
else:
self.logger.warning("Deployment package is empty; skipping deployment.")
return

return self.api_class(
self,
Expand Down Expand Up @@ -113,9 +117,12 @@ def _get_package_zip(self, path):
"namespaced_org": self._is_namespaced_org(namespace),
}

return MetadataPackageZipBuilder(
package_zip = MetadataPackageZipBuilder(
path=path, options=options, logger=self.logger
).as_base64()
)
if not package_zip.zf.namelist():
return
return package_zip.as_base64()

def freeze(self, step):
steps = super(Deploy, self).freeze(step)
Expand Down
13 changes: 13 additions & 0 deletions cumulusci/tasks/salesforce/tests/test_Deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ def test_get_api__static_resources(self):
self.assertIn("<name>StaticResource</name>", package_xml)
self.assertIn("<members>TestBundle</members>", package_xml)

def test_get_api__empty_package_zip(self):
with temporary_dir() as path:
task = create_task(
Deploy,
{
"path": path,
"unmanaged": True,
},
)

api = task._get_api()
assert api is None

def test_init_options(self):
with self.assertRaises(TaskOptionsError):
create_task(
Expand Down

0 comments on commit fe1d735

Please sign in to comment.