Testing
All tests have the following structure:
def test_foo(self):
data = {...}
expected_valid = True # or False
expected = {...} # or omitted
# setup (without serializer)
...
# testing
serializer = MyParentSerializer(data=data, ...)
# validate data
assert serializer.is_valid() == expected_valid, serializer.errors
# derserialization
instance = serializer.save()
# serialization
result = MyParentSerializer(instance=instance).data
# validate result
assert result == expected, f"\nResult: {result}\nExpected: {expected}"
Relationships
Action | Nested Data | Previous Nested | One to One | One to One Rel | Foreign Key | Many to One Rel | Many to Many | Many to Many Rel | Through |
---|---|---|---|---|---|---|---|---|---|
Create | Omit | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Create | None |
- | ✅ | ✅ | ✅ | - | - | - | - |
Create | Empty | - | - | - | - | ✅ | ✅ | ✅ | ✅ |
Create | Without pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Create | With None pk |
- | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Create | Only pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Create | With pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Create | Multiple | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | Omit | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | Omit | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | None |
- | ✅ | ✅ | ✅ | - | - | - | - |
Update | None |
✓ | ✅ | ✅ | ✅ | - | - | - | - |
Update | Empty | - | - | - | - | ✅ | ✅ | ✅ | ✅ |
Update | Empty | ✓ | - | - | - | ✅ | ✅ | ✅ | ✅ |
Update | Without pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | Without pk | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | With None pk |
- | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | With None pk |
✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | Only pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - |
Update | Only pk | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - |
Update | Only same pk | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - |
Update | With pk | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - |
Update | With pk | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - |
Update | With same pk | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Update | Multiple | - | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | TODO |
Update | Multiple | ✓ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | TODO |
Other
- Non-nullable: ✅
- Nesting: ✅
- Source: TODO
- Write-only: TODO
- Delete-action: TODO
- Partial update: TODO
- Allow empty: TODO
- Allow null: TODO
- Doc examples: TODO
- Validation: TODO