Skip to content

BestPractices

peder2911 edited this page May 21, 2021 · 2 revisions

Best Practices

This page contains a set of guidelines that should be followed when making contributions to ViEWS 3. The purpose of these guidelines is to ensure long-term maintainability and stability for the codebase.

Testing

All non-trivial code should be tested. Libraries we use are assumed to be tested and stable, but all custom logic and operations should have associated unit tests.

Use whatever test library you want, the unittest module is fine.

Testing code that makes HTTP calls or depends on a database is no problem if you use the right tools for the job. For mocking HTTP requests, use httpretty. For mocking SQL Alchemy sessions, use UnifiedAlchemyMagicMock from alchemy-mock.

Consistency

For each service, one should use one and only one tool in each domain. This means that if a service uses SQL Alchemy for its database operations, then you should write database code for that service using something else. In similar fashion, if a service uses unittest for its tests, then you need to write tests with unittest.