def lambda_handler(event, context): logger.info("event: %s" % json.dumps(event)) sf = Salesforce(version=get_arg(os.environ, "SF_VERSION"), consumer_key=get_arg(os.environ, "SF_CONSUMER_KEY"), consumer_secret=get_arg(os.environ, "SF_CONSUMER_SECRET"), username=get_arg(os.environ, "SF_USERNAME"), password=get_arg(os.environ, "SF_PASSWORD") + get_arg(os.environ, "SF_ACCESS_TOKEN")) if get_arg(os.environ, "SF_PRODUCTION").lower() == "true": sf.set_production() sf.sign_in() resp = create(sf=sf, **event['Details']['Parameters']) logger.info("result: %s" % resp) return resp
def test_get_arg_not_present(self): with self.assertRaises(Exception): get_arg({}, "KEY")
def test_get_arg(self): env = {'KEY': 1234} key = get_arg(env, "KEY") self.assertEqual(1234, key)