Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: filesystem and database are not treated as injectable dependencies #249

Open
jrwdunham opened this issue Oct 17, 2017 · 1 comment

Comments

@jrwdunham
Copy link
Contributor

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.

Refactoring SS to include dependency injection could proceed via the StranglerApplication approach/pattern.

@jrwdunham
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants