{"id":27116691,"url":"https://github.com/kicksaw-consulting/simple-mockforce","last_synced_at":"2025-04-07T05:43:24.433Z","repository":{"id":38299994,"uuid":"359169867","full_name":"Kicksaw-Consulting/simple-mockforce","owner":"Kicksaw-Consulting","description":"A companion package for simple-salesforce that enables the testing of code that interacts with Salesforce's API","archived":false,"fork":false,"pushed_at":"2024-04-17T20:14:51.000Z","size":170,"stargazers_count":15,"open_issues_count":5,"forks_count":7,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-27T14:55:37.035Z","etag":null,"topics":["python","salesforce","simple-salesforce","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kicksaw-Consulting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-18T14:44:41.000Z","updated_at":"2024-11-05T06:58:46.000Z","dependencies_parsed_at":"2024-06-21T20:22:20.542Z","dependency_job_id":"c3be35fa-aee7-45c5-8f81-a158db0f6a25","html_url":"https://github.com/Kicksaw-Consulting/simple-mockforce","commit_stats":{"total_commits":156,"total_committers":7,"mean_commits":"22.285714285714285","dds":0.09615384615384615,"last_synced_commit":"d6f176d7eda418bf5b15ee39303cff8564f4e2aa"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kicksaw-Consulting%2Fsimple-mockforce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kicksaw-Consulting%2Fsimple-mockforce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kicksaw-Consulting%2Fsimple-mockforce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kicksaw-Consulting%2Fsimple-mockforce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kicksaw-Consulting","download_url":"https://codeload.github.com/Kicksaw-Consulting/simple-mockforce/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601492,"owners_count":20964863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","salesforce","simple-salesforce","testing"],"created_at":"2025-04-07T05:43:24.023Z","updated_at":"2025-04-07T05:43:24.425Z","avatar_url":"https://github.com/Kicksaw-Consulting.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis library was inspired by [moto](https://github.com/spulec/moto) and mimics some of its design. Mainly,\nno `simple-salesforce` code is patched; instead, the HTTP calls it makes are intercepted, and state is\nstored in an in-memory, virtual Salesforce organization, which is just a globally instantiated class that\nis created at the run-time of a test-suite.\n\n# Installation\n\n`pip install simple-mockforce`\n\nor, with poetry\n\n`poetry add simple-mockforce`\n\n# Usage\n\nTo patch calls to the Salesforce API and instead interact with the \"virtual\"\nSalesforce organization provided by this library, add the following:\n\n```python\nimport os\n\nfrom simple_mockforce import mock_salesforce\n\nfrom simple_salesforce import Salesforce\n\n\n@mock_salesforce\ndef test_api():\n    # The username, password, and security token are ignored - any value will work.\n    salesforce = Salesforce(\n        username=os.getenv(\"SFDC_USERNAME\"),\n        password=os.getenv(\"SFDC_PASSWORD\"),\n        security_token=os.getenv(\"SFDC_SECURITY_TOKEN\")\n    )\n\n    response = salesforce.Account.create({\"Name\": \"Test Account\"})\n\n    account_id = response[\"id\"]\n\n    account = salesforce.Account.get(account_id)\n\n    assert account[\"Name\"] == \"Test Account\"\n```\n\nAnd that's about it!\n\n# Caveats\n\n## Case sensitivity\n\nUnlike a real Salesforce organization, the virtual organization will not handle case-insensitive\ndependent code for you. You must remain consistent with your casing of object and field\nnames in all aspects of the code.\n\n## Missing endpoints\n\nThe following features are currently not supported:\n\n- the describe API\n- bulk queries\n- SOSL searches\n\n## Queries\n\nSOQL is only partially supported as of now. Please refer to the README\nfor [python-soql-parser](https://github.com/Kicksaw-Consulting/python-soql-parser#notable-unsupported-features)\nto see what's not yet implemented.\n\nYou should only expect this library to be able to mock the most basic of queries.\nWhile there are plans to, mocking query calls which traverse object relationships\nor that use SOQL-specific where-clause tokens are not yet supported.\n\nNotable mentions:\n\n- be explicit with direction in `ORDER BY` clauses, i.e., always supply `DESC` or `ASC`\n- attributes of parent objects can be specified in the `select` clause (but not in the `where` clause)\n\n## Error handling\n\nError handling is only mocked to a degree, and for some calls it isn't at all.\nThis is because the virtual Salesforce organization does not yet enforce any of\nthe server-side validation you might encounter when working with the real API.\n\nThis means that the virtual organization is much more permissive and loose than a\nreal Salesforce organization would be.\n\nThere are plans to read the XML consumed by the meta API in order to enforce\nmore rigidity inside the virtual organization, but this is not yet implemented.\n\n## All HTTP traffic is blocked\n\nWhen using `@mock_salesforce`, do note that the `requests` library is being\npatched with `responses`, so any calls you make to any other APIs will fail\nunless you patch them yourself, or patch the code which invokes said calls.\n\n## Relations\n\nRelations are the weakest part of this library, and some features are just\nplain not supported yet.\n\nIf you have a relational field that points to an object whose name cannot be\ninferred from the field name (e.g., from `Account__r` it can be inferred\nthat this is pointing to an `Account` object), you can create a file called\n`relations.json` that translates a relational field name to your intended\nSalesforce object's name. See `relations.json` in the test folder for an\nexample.\n\nTo specify the location of `relations.json`, set an environment variable\ncalled `MOCKFORCE_RELATIONS_ROOT` which points to the parent folder of\n`relations.json`. Note, this defaults to the current directory `.`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkicksaw-consulting%2Fsimple-mockforce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkicksaw-consulting%2Fsimple-mockforce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkicksaw-consulting%2Fsimple-mockforce/lists"}