From b20b6f5a3cc412e201817ad870407caeb6b9352f Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Thu, 18 May 2023 07:11:58 +0000 Subject: automatic import of python-simple-mockforce --- python-simple-mockforce.spec | 412 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 412 insertions(+) create mode 100644 python-simple-mockforce.spec (limited to 'python-simple-mockforce.spec') diff --git a/python-simple-mockforce.spec b/python-simple-mockforce.spec new file mode 100644 index 0000000..fa2f372 --- /dev/null +++ b/python-simple-mockforce.spec @@ -0,0 +1,412 @@ +%global _empty_manifest_terminate_build 0 +Name: python-simple-mockforce +Version: 0.8.0 +Release: 1 +Summary: A companion package for simple-salesforce that enables the testing of code that interacts with Salesforce's API +License: MIT +URL: https://github.com/Kicksaw-Consulting/simple-mockforce +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/31/9c/4310ac28ae5492bbdcc3c8ceaf5a785975602a5b7501245589646ce7fbb6/simple-mockforce-0.8.0.tar.gz +BuildArch: noarch + +Requires: python3-soql-parser +Requires: python3-dateutil +Requires: python3-responses +Requires: python3-decorator + +%description +# Introduction + +This library was inspired by [moto](https://github.com/spulec/moto) and mimics some of its design. Mainly, +no `simple-salesforce` code is patched; instead, the HTTP calls it makes are intercepted, and state is +stored in an in-memory, virtual Salesforce organization, which is just a globally instantiated class that +is created at the run-time of a test-suite. + +# Installation + +`pip install simple-mockforce` + +or, with poetry + +`poetry add simple-mockforce` + +# Usage + +To patch calls to the Salesforce API and instead interact with the "virtual" +Salesforce organization provided by this library, add the following: + +```python +import os + +from simple_mockforce import mock_salesforce + +from simple_salesforce import Salesforce + + +@mock_salesforce +def test_api(): + # The username, password, and security token are ignored - any value will work. + salesforce = Salesforce( + username=os.getenv("SFDC_USERNAME"), + password=os.getenv("SFDC_PASSWORD"), + security_token=os.getenv("SFDC_SECURITY_TOKEN") + ) + + response = salesforce.Account.create({"Name": "Test Account"}) + + account_id = response["id"] + + account = salesforce.Account.get(account_id) + + assert account["Name"] == "Test Account" +``` + +And that's about it! + +# Caveats + +## Case sensitivity + +Unlike a real Salesforce organization, the virtual organization will not handle case-insensitive +dependent code for you. You must remain consistent with your casing of object and field +names in all aspects of the code. + +## Missing endpoints + +The following features are currently not supported: + +- the describe API +- bulk queries +- SOSL searches + +## Queries + +SOQL is only partially supported as of now. Please refer to the README +for [python-soql-parser](https://github.com/Kicksaw-Consulting/python-soql-parser#notable-unsupported-features) +to see what's not yet implemented. + +You should only expect this library to be able to mock the most basic of queries. +While there are plans to, mocking query calls which traverse object relationships +or that use SOQL-specific where-clause tokens are not yet supported. + +Notable mentions: + +- be explicit with direction in `ORDER BY` clauses, i.e., always supply `DESC` or `ASC` +- attributes of parent objects can be specified in the `select` clause (but not in the `where` clause) + +## Error handling + +Error handling is only mocked to a degree, and for some calls it isn't at all. +This is because the virtual Salesforce organization does not yet enforce any of +the server-side validation you might encounter when working with the real API. + +This means that the virtual organization is much more permissive and loose than a +real Salesforce organization would be. + +There are plans to read the XML consumed by the meta API in order to enforce +more rigidity inside the virtual organization, but this is not yet implemented. + +## All HTTP traffic is blocked + +When using `@mock_salesforce`, do note that the `requests` library is being +patched with `responses`, so any calls you make to any other APIs will fail +unless you patch them yourself, or patch the code which invokes said calls. + +## Relations + +Relations are the weakest part of this library, and some features are just +plain not supported yet. + +If you have a relational field that points to an object whose name cannot be +inferred from the field name (e.g., from `Account__r` it can be inferred +that this is pointing to an `Account` object), you can create a file called +`relations.json` that translates a relational field name to your intended +Salesforce object's name. See `relations.json` in the test folder for an +example. + +To specify the location of `relations.json`, set an environment variable +called `MOCKFORCE_RELATIONS_ROOT` which points to the parent folder of +`relations.json`. Note, this defaults to the current directory `.`. + + +%package -n python3-simple-mockforce +Summary: A companion package for simple-salesforce that enables the testing of code that interacts with Salesforce's API +Provides: python-simple-mockforce +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-simple-mockforce +# Introduction + +This library was inspired by [moto](https://github.com/spulec/moto) and mimics some of its design. Mainly, +no `simple-salesforce` code is patched; instead, the HTTP calls it makes are intercepted, and state is +stored in an in-memory, virtual Salesforce organization, which is just a globally instantiated class that +is created at the run-time of a test-suite. + +# Installation + +`pip install simple-mockforce` + +or, with poetry + +`poetry add simple-mockforce` + +# Usage + +To patch calls to the Salesforce API and instead interact with the "virtual" +Salesforce organization provided by this library, add the following: + +```python +import os + +from simple_mockforce import mock_salesforce + +from simple_salesforce import Salesforce + + +@mock_salesforce +def test_api(): + # The username, password, and security token are ignored - any value will work. + salesforce = Salesforce( + username=os.getenv("SFDC_USERNAME"), + password=os.getenv("SFDC_PASSWORD"), + security_token=os.getenv("SFDC_SECURITY_TOKEN") + ) + + response = salesforce.Account.create({"Name": "Test Account"}) + + account_id = response["id"] + + account = salesforce.Account.get(account_id) + + assert account["Name"] == "Test Account" +``` + +And that's about it! + +# Caveats + +## Case sensitivity + +Unlike a real Salesforce organization, the virtual organization will not handle case-insensitive +dependent code for you. You must remain consistent with your casing of object and field +names in all aspects of the code. + +## Missing endpoints + +The following features are currently not supported: + +- the describe API +- bulk queries +- SOSL searches + +## Queries + +SOQL is only partially supported as of now. Please refer to the README +for [python-soql-parser](https://github.com/Kicksaw-Consulting/python-soql-parser#notable-unsupported-features) +to see what's not yet implemented. + +You should only expect this library to be able to mock the most basic of queries. +While there are plans to, mocking query calls which traverse object relationships +or that use SOQL-specific where-clause tokens are not yet supported. + +Notable mentions: + +- be explicit with direction in `ORDER BY` clauses, i.e., always supply `DESC` or `ASC` +- attributes of parent objects can be specified in the `select` clause (but not in the `where` clause) + +## Error handling + +Error handling is only mocked to a degree, and for some calls it isn't at all. +This is because the virtual Salesforce organization does not yet enforce any of +the server-side validation you might encounter when working with the real API. + +This means that the virtual organization is much more permissive and loose than a +real Salesforce organization would be. + +There are plans to read the XML consumed by the meta API in order to enforce +more rigidity inside the virtual organization, but this is not yet implemented. + +## All HTTP traffic is blocked + +When using `@mock_salesforce`, do note that the `requests` library is being +patched with `responses`, so any calls you make to any other APIs will fail +unless you patch them yourself, or patch the code which invokes said calls. + +## Relations + +Relations are the weakest part of this library, and some features are just +plain not supported yet. + +If you have a relational field that points to an object whose name cannot be +inferred from the field name (e.g., from `Account__r` it can be inferred +that this is pointing to an `Account` object), you can create a file called +`relations.json` that translates a relational field name to your intended +Salesforce object's name. See `relations.json` in the test folder for an +example. + +To specify the location of `relations.json`, set an environment variable +called `MOCKFORCE_RELATIONS_ROOT` which points to the parent folder of +`relations.json`. Note, this defaults to the current directory `.`. + + +%package help +Summary: Development documents and examples for simple-mockforce +Provides: python3-simple-mockforce-doc +%description help +# Introduction + +This library was inspired by [moto](https://github.com/spulec/moto) and mimics some of its design. Mainly, +no `simple-salesforce` code is patched; instead, the HTTP calls it makes are intercepted, and state is +stored in an in-memory, virtual Salesforce organization, which is just a globally instantiated class that +is created at the run-time of a test-suite. + +# Installation + +`pip install simple-mockforce` + +or, with poetry + +`poetry add simple-mockforce` + +# Usage + +To patch calls to the Salesforce API and instead interact with the "virtual" +Salesforce organization provided by this library, add the following: + +```python +import os + +from simple_mockforce import mock_salesforce + +from simple_salesforce import Salesforce + + +@mock_salesforce +def test_api(): + # The username, password, and security token are ignored - any value will work. + salesforce = Salesforce( + username=os.getenv("SFDC_USERNAME"), + password=os.getenv("SFDC_PASSWORD"), + security_token=os.getenv("SFDC_SECURITY_TOKEN") + ) + + response = salesforce.Account.create({"Name": "Test Account"}) + + account_id = response["id"] + + account = salesforce.Account.get(account_id) + + assert account["Name"] == "Test Account" +``` + +And that's about it! + +# Caveats + +## Case sensitivity + +Unlike a real Salesforce organization, the virtual organization will not handle case-insensitive +dependent code for you. You must remain consistent with your casing of object and field +names in all aspects of the code. + +## Missing endpoints + +The following features are currently not supported: + +- the describe API +- bulk queries +- SOSL searches + +## Queries + +SOQL is only partially supported as of now. Please refer to the README +for [python-soql-parser](https://github.com/Kicksaw-Consulting/python-soql-parser#notable-unsupported-features) +to see what's not yet implemented. + +You should only expect this library to be able to mock the most basic of queries. +While there are plans to, mocking query calls which traverse object relationships +or that use SOQL-specific where-clause tokens are not yet supported. + +Notable mentions: + +- be explicit with direction in `ORDER BY` clauses, i.e., always supply `DESC` or `ASC` +- attributes of parent objects can be specified in the `select` clause (but not in the `where` clause) + +## Error handling + +Error handling is only mocked to a degree, and for some calls it isn't at all. +This is because the virtual Salesforce organization does not yet enforce any of +the server-side validation you might encounter when working with the real API. + +This means that the virtual organization is much more permissive and loose than a +real Salesforce organization would be. + +There are plans to read the XML consumed by the meta API in order to enforce +more rigidity inside the virtual organization, but this is not yet implemented. + +## All HTTP traffic is blocked + +When using `@mock_salesforce`, do note that the `requests` library is being +patched with `responses`, so any calls you make to any other APIs will fail +unless you patch them yourself, or patch the code which invokes said calls. + +## Relations + +Relations are the weakest part of this library, and some features are just +plain not supported yet. + +If you have a relational field that points to an object whose name cannot be +inferred from the field name (e.g., from `Account__r` it can be inferred +that this is pointing to an `Account` object), you can create a file called +`relations.json` that translates a relational field name to your intended +Salesforce object's name. See `relations.json` in the test folder for an +example. + +To specify the location of `relations.json`, set an environment variable +called `MOCKFORCE_RELATIONS_ROOT` which points to the parent folder of +`relations.json`. Note, this defaults to the current directory `.`. + + +%prep +%autosetup -n simple-mockforce-0.8.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-simple-mockforce -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot - 0.8.0-1 +- Package Spec generated -- cgit v1.2.3