The back-end must support this change by updating:
The model (jukebox_radio.streams.models.marker)
The API (jukebox_radio.streams.views.marker.create_view)
The test (jukebox_radio.streams.tests.views.marker.test_create_view)
1. The model
The Marker model (inside the streams app) needs to be modified. A new field needs to be added:
name = models.CharField(max_length=32)
After adding the new field, you will have to makemigrations. To do this, go to the terminal and run:
docker-compose -f local.yml run --rm django python manage.py makemigrations
Now since the field you added requires a value for all Marker entries, and there are existing Marker entries, all existing entries will have to be backfilled with a default value. As such, you will want to set the default for existing values as the following string: "Default".
2. The API
All the changes for the API will be made inside jukebox_radio.streams.models.marker.
The application will send the backend a new parameter: name. The code should read this value and then make sure to pass it inside Marker.objects.create(... name=name) so that the name is actually saved in the database.
2. The test
Try running this in the terminal:
docker-compose -f local.yml run --rm django pytest
You'll notice that it fails - which is good! If you are wondering why this is good, let me know and I can further explain.
So, you're going to want to open up the test that is failing and fix it. To do this, you will need to add to data a test name. You also will want to add 2 assertions to the bottom of the test: one to verify the behavior for the API response, and one to verify the DB state.
Summary
As per the new spec, when a user creates a marker on a track, they should be able to name that marker.
Definition of "marker."
The back-end must support this change by updating:
jukebox_radio.streams.models.marker
)jukebox_radio.streams.views.marker.create_view
)jukebox_radio.streams.tests.views.marker.test_create_view
)1. The model
The
Marker
model (inside thestreams
app) needs to be modified. A new field needs to be added:After adding the new field, you will have to
makemigrations
. To do this, go to the terminal and run:Now since the field you added requires a value for all
Marker
entries, and there are existingMarker
entries, all existing entries will have to be backfilled with a default value. As such, you will want to set the default for existing values as the following string:"Default"
.2. The API
All the changes for the API will be made inside
jukebox_radio.streams.models.marker
.The application will send the backend a new parameter:
name
. The code should read this value and then make sure to pass it insideMarker.objects.create(... name=name)
so that the name is actually saved in the database.2. The test
Try running this in the terminal:
You'll notice that it fails - which is good! If you are wondering why this is good, let me know and I can further explain.
So, you're going to want to open up the test that is failing and fix it. To do this, you will need to add to
data
a testname
. You also will want to add 2 assertions to the bottom of the test: one to verify the behavior for the API response, and one to verify the DB state.