Add base models and field definitions with unit tests#8
Add base models and field definitions with unit tests#8
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the foundational structure for the omnizen package by adding base models and field definitions with comprehensive unit tests. The implementation establishes an abstract base model with required CRUD operations and utility methods, along with specialized field types for enhanced data modeling.
Key changes:
- Implements a BaseModel class with abstract methods for CRUD operations and utility methods for field introspection
- Creates NameField function for handling unique and autoincrement field types with schema extensions
- Develops a Choices enum class for creating type-safe choice fields with automatic label generation
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| omnizen/models/base.py | Defines abstract BaseModel class with CRUD operations and field utility methods |
| omnizen/fields/base.py | Implements NameField function with type validation and schema customization |
| omnizen/fields/types.py | Creates Choices enum class with metaclass for choice field functionality |
| tests/unit/models/test_base_model.py | Comprehensive unit tests for BaseModel functionality and field integration |
| tests/unit/fields/test_fields.py | Unit tests for NameField function and Choices enum class |
| omnizen/models/init.py | Package initialization for models module |
| omnizen/fields/init.py | Package initialization for fields module |
| tests/unit/models/init.py | Test package initialization for models tests |
| tests/unit/fields/init.py | Test package initialization for fields tests |
41dd108 to
d127b47
Compare
omnizen/fields/base.py
Outdated
|
|
||
| kwargs["json_schema_extra"] = enhanced_schema | ||
| else: | ||
| kwargs["json_schema_extra"] = {**existing_schema, **our_schema} |
There was a problem hiding this comment.
o que entraria aqui nesse json_schema_extra?
There was a problem hiding this comment.
O Json Schema é a forma possível da gente passar os parâmetros personalizados do NameField para usarmos na criação da model. Originalmente ele funciona para agregar ao JSON de cada field, podendo até receber funções.
Por isso temos que fazer essa validação.
| def NameField( | ||
| name_type: Optional[NameFieldType], | ||
| **kwargs, | ||
| ): ... |
There was a problem hiding this comment.
esses overloads parecem meio redundantes, não?
There was a problem hiding this comment.
Sem o último os args do autoincrement aparecem quando a classe ainda não possui nenhum argumento, com ele só aparecem ao selecionar o name_type="autoincrement"
d127b47 to
5049b8e
Compare
feat(fields, models): add base models and field definitions with unit tests
Resolves #7