Skip to content

Add base models and field definitions with unit tests#8

Open
oLeoz1n wants to merge 2 commits intomainfrom
7-models-and-fields
Open

Add base models and field definitions with unit tests#8
oLeoz1n wants to merge 2 commits intomainfrom
7-models-and-fields

Conversation

@oLeoz1n
Copy link
Contributor

@oLeoz1n oLeoz1n commented Aug 7, 2025

feat(fields, models): add base models and field definitions with unit tests

Resolves #7

@oLeoz1n oLeoz1n requested a review from leonextlevel August 7, 2025 14:45
@oLeoz1n oLeoz1n self-assigned this Aug 7, 2025
Copilot AI review requested due to automatic review settings August 7, 2025 14:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


kwargs["json_schema_extra"] = enhanced_schema
else:
kwargs["json_schema_extra"] = {**existing_schema, **our_schema}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o que entraria aqui nesse json_schema_extra?

Copy link
Contributor Author

@oLeoz1n oLeoz1n Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

link

def NameField(
name_type: Optional[NameFieldType],
**kwargs,
): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esses overloads parecem meio redundantes, não?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precisa desse último?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@oLeoz1n oLeoz1n force-pushed the 7-models-and-fields branch from d127b47 to 5049b8e Compare August 8, 2025 11:19
@oLeoz1n oLeoz1n deployed to Development August 8, 2025 11:19 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create BaseModel and Fields

3 participants