You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The storage service contains pervasive calls to filesystem APIs (os, sys, shutil) and database APIs (Django models, Elasticsearch). If classes like package.py::Package explicitly declared dependencies on objects (say fs or db) and the APIs they required, then those dependencies could more easily be swapped out in different environments, e.g., during testing or when digital objects are accessed not from a Unix filesystem but from an S3 store.
One immediate benefit of such a refactoring would be that unit and functional tests could be made to run much more quickly. If instead of creating test databases and test directory structures we swapped in mock dependencies, the runtime of these tests could probably be significantly decreased.
The metsrw PR 27 illustrates a strategy for dependency injection that might be applicable here.
Relatedly, this strategy could allow us to clean up the space-related code and make spaces pluggable dependencies, which could allow users to avoid installing unneeded third party dependencies for space types that they never use.
Changing the source as per this issue might not even be necessary. It may simply be necessary to improve how we write tests. See artefactual/archivematica#772
The storage service contains pervasive calls to filesystem APIs (
os
,sys
,shutil
) and database APIs (Djangomodels
, Elasticsearch). If classes likepackage.py::Package
explicitly declared dependencies on objects (sayfs
ordb
) and the APIs they required, then those dependencies could more easily be swapped out in different environments, e.g., during testing or when digital objects are accessed not from a Unix filesystem but from an S3 store.One immediate benefit of such a refactoring would be that unit and functional tests could be made to run much more quickly. If instead of creating test databases and test directory structures we swapped in mock dependencies, the runtime of these tests could probably be significantly decreased.
The metsrw PR 27 illustrates a strategy for dependency injection that might be applicable here.
Relatedly, this strategy could allow us to clean up the space-related code and make spaces pluggable dependencies, which could allow users to avoid installing unneeded third party dependencies for space types that they never use.
Refactoring SS to include dependency injection could proceed via the StranglerApplication approach/pattern.
The text was updated successfully, but these errors were encountered: