Giter Site home page Giter Site logo

immotest's Introduction

immotest

a test

Requirements

  • Python 3.8+

Development

Local development

First, create a .env file containing the settings:

DOMAIN=localhost
STACK_NAME=test
DOCKER_IMAGE_BACKEND=backend

# Backend
PROJECT_NAME=immotest
SECRET_KEY=xyz
[email protected]
FIRST_SUPERUSER_PASSWORD=zyx
LOG_LEVEL=debug
FETCH_ARTIST_DELAY=30.0
# Spotify API
SPOTIFY_CLIENT_ID=xyz
SPOTIFY_CLIENT_SECRET=zyx

# Postgres
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=app
SQLALCHEMY_DATABASE_URI=postgresql+asyncpg://postgres:postgres@db/app

INSTALL_DEV=false

Then, start the stack with Docker Compose:

# Build services
docker-compose build

# Create and start containers
docker-compose up -d

# Show the logs of the API backend (and background Spotify task)
docker-compose logs -f api

Operation

Open your browser and interact with the API via:

And interact with the DB via :

Nota Bene: the Spotify connector does not refresh its token. So it will stop working when it expires (one hour). If needed, the functionality to refresh it could be addded.

Tests

Nota Bene: this code is far from being complete, but it does what was asked. Specifically, the tests can be increased of course, especially to test the background Spotify fetcher (both the connector and the fetcher service itself) by mocking Spotify with the respx library.

Start the stack & run tests with this command:

./scripts/test-local.sh

If your stack is already up, you just want to run the tests, you can use:

docker-compose exec api /app/scripts/tests-start.sh

Migrations

After changing a model (for example, adding a column), create a revision, e.g.:

docker-compose run api alembic revision --autogenerate -m "Add column last_name to User model"

After creating the revision, run the migration in the database (this is what will actually change the database):

$ docker-compose run api alembic upgrade head

immotest's People

Contributors

pynchia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.