Package: fake-store
Fake StoreWith fake-store, the implementation of a hexagonal architecture in python whose repositories are testable becomes
very simple.This library is able to make hydrated entities from yaml files. It will let use them directly.
This is the ideal library for building your fake server that replaces your database in automatic tests.classFakePetRepository:def__init__(self):self._store:List[Pet]=fake_store.load_collection(Pet,"pet.yml")defstore(self,pet:Pet):self._store.append(pet)...The librarie takes care of :loading nested object inside each otherconverting objects to their native python typetake controle of objects generation through a factoryworks well withdataclassandattrsimplement a share memory store and resettable memory store to share datasets between repositoriesGetting startedpip install fake-storeThe latest versionYou can find the latest version to ...gitclonehttps://github.com/FabienArcellier/fake-store.gitUsageBinding _class in definition with real python classYou can run the application with the following commandimportfake_storefrommyapp.domain.entity.petimportPetfake_store.bind_class(Pet.__name__,Pet)Any objects that contains_class: Petin definition will be instanciated asPet-__class:Petname:"Ronny"status:available-__class:Petname:"Crane"status:unavailableThe class Pet has to defined it's__init__method with the 2 keyword arguments. If an argument is missing or
doesn't exist in the construct, it will raise an errorclassPet:def__init__(self,name:str,status:str):passlook atexamples/nested_fake_store.pyuse a factory method instead ofinitmethodseeexamples/factory_fake_store.pyuse a memory store to share the same data between several repositoryseeexamples/memory_store.pyuse a resettable memory store to share the same data between several repository on automatic testData loading can become slower and slower over time. If it is played between each test, it adds
1s of overhead on every test. In a CI or on the development workstation, it is interesting to avoid
this loading time.TheResettableStoreclass allows between each test to restore the content of the store to its original state in one step
negligible with the call toreset_store.seeexamples/resettable_store.pyDevelopper guidelineactivate                       activate the virtualenv associate with this project
coverage                       output the code coverage in htmlcov/index.html
help                           provides cli help for this makefile (default)
install_requirements_dev       install pip requirements for development
install_requirements           install pip requirements based on requirements.txt
lint                           run pylint
tests                          run automatic tests
tests_units                    run only unit tests
twine                          publish on pypi
update_requirements            update the project dependencies based on setup.py declarationInstall development environmentUse make to instanciate a python virtual environment in ./venv and install the
python dependencies.makeinstall_requirements_devInstall production environmentmakeinstall_requirementsInitiate or update the library requirementsIf you want to initiate or update all the requirementsinstall_requiresdeclared insetup.pyand freeze a newPipfile.lock, use this commandmakeupdate_requirementsActivate the python environmentWhen you setup the requirements, avenvdirectory on python 3 is created.
To activate the venv, you have to execute :makevenvsourcevenv/bin/activateRun the linter and the unit testsBefore commit or send a pull request, you have to executepylintto check the syntax
of your code and run the unit tests to validate the behavior.makelint
maketestsContributorsFabien ArcellierLicenseMIT LicenseCopyright (c) 2018 Fabien ArcellierPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.