Skip to content

Commit

Permalink
fix: add filenames for the code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
fyliu authored and joey-ma committed Mar 10, 2023
1 parent 57c4870 commit dc49007
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/how-to/add-model-and-api-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Let's start!

### Add the model in django

Add the following to app/core/models.py

```python
class RecurringEvent(AbstractBaseModel):
"""
Expand Down Expand Up @@ -75,6 +77,10 @@ Since we overrode the `__str__` function, we need to write a test for it.

Fixtures are reusable code that can be used in multiple tests by declaring them as parameters of the test case. In this example, we show both defining a fixture (recurring_event) and using another fixture (project).

Note: The conftest file is meant to hold shared test fixtures, among other things. The fixtures have directory scope.

Add the following to app/core/tests/conftest.py

```python
@pytest.fixture
def recurring_event(project):
Expand All @@ -93,6 +99,8 @@ Since we overrode the `__str__` function, we need to write a test for it.

Here's a basic test to see that the model stores its name.

Add the following to app/core/tests/test_models.py

```python
def test_recurring_event(recurring_event):
assert str(recurring_event) == "Test Recurring Event"
Expand Down

0 comments on commit dc49007

Please sign in to comment.