def test_deploy_fail_process(self, popen_func): popen_mock = Mock() attrs = {'wait.return_value': 1} popen_mock.configure_mock(**attrs) popen_func.return_value = popen_mock try: path = os.getcwd() test_deploy = LambdaDeploy(path, "s3://pb-gravity", None) test_deploy.deploy() except Exception as e: popen_mock.wait.assert_any_call() self.assertTrue(popen_mock.wait.call_count == 1, "Popen.wait was called more than once before failing!")
def test_deploy_success(self, archive_func, popen_func): popen_mock = Mock() popen_attrs = {'wait.return_value': 0} popen_mock.configure_mock(**popen_attrs) popen_func.return_value = popen_mock shutil_attrs = {'make_archive.return_value': True} archive_func.configure_mock(**shutil_attrs) try: path = os.getcwd() test_deploy = LambdaDeploy(path, "s3://my_bucket", None) test_deploy.deploy() popen_mock.wait.assert_any_call() self.assertTrue(popen_mock.wait.call_count == 4, "Popen.wait has the incorrect number of calls!") self.assertTrue(archive_func.call_count == 1, "Did not call make_archive!") except Exception as e: print(e) self.assertTrue(False, "Unable to deploy!")