dadosfera 1.22.0
Biblioteca Dadosfera para processamento e análise de dados
License: MIT
Requires Python: <4.0,>=3.6.2
Keywords: data, analysis, processing, dadosfera

# Dadosfera Library


A Dadosfera Library é uma biblioteca Python que fornece ferramentas e utilitários para processamento e análise de dados, incluindo funcionalidades para envio de emails, manipulação de dados e integração com diversos serviços.

## Funcionalidades

A biblioteca oferece diversas funcionalidades para processamento e análise de dados:

- **EmailSender**: Envio de emails com suporte a múltiplos destinatários, anexos e formatos HTML/texto
- **Processamento de Dados**: Ferramentas para manipulação e transformação de dados
- **Integrações**: Conectores para diversos serviços e APIs
- **Análise de Dados**: Utilitários para análise e visualização de dados
- **Machine Learning**: Suporte para modelos de ML e processamento de dados para ML

Para ver a lista completa de funcionalidades e documentação detalhada, visite nossa [documentação oficial](https://docs.dadosfera.ai/page/dadosfera-library).

## Instalação

### Via pip
```bash
pip install dadosfera
```

### Via Poetry
```bash
poetry add dadosfera
```

## Uso

### Exemplo Básico
```python
from dadosfera import EmailSender

# Configurar o sender
sender = EmailSender(
    smtp_server="smtp.gmail.com",
    port=587,
    from_email="seu@email.com",
    password="sua_senha",
    use_ssl=True
)

# Criar e enviar um email
message = sender.create_message(
    to_email="destinatario@email.com",
    subject="Teste",
    body="Olá, este é um teste!",
    mimetype="html"  # ou "plain" para texto plano
)

# Enviar o email
sender.send_email("destinatario@email.com", message)
```

Para mais exemplos e casos de uso, consulte nossa [documentação oficial](https://docs.dadosfera.ai/page/dadosfera-library).

## Desenvolvimento

### Pré-requisitos
- Python 3.6.2 ou superior
- Docker e Docker Compose
- Poetry (para gerenciamento de dependências)

### Configuração do Ambiente

1. Clone o repositório:
```bash
git clone https://github.com/dadosfera/dadosfera-library.git
cd dadosfera-library
```

2. Instale as dependências:
```bash
poetry install
```

### Executando os Testes

1. Configure as variáveis de ambiente:
```bash
cp test.env.example test.env
# Edite o arquivo test.env com suas configurações
```

2. Execute os testes:
```bash
docker-compose -f test.local.docker-compose.yml build
docker-compose -f test.local.docker-compose.yml run test_suite
```

## Contribuindo

1. Faça um fork do projeto
2. Crie uma branch para sua feature (`git checkout -b feature/nova-feature`)
3. Faça commit das suas mudanças (`git commit -m 'feat: adiciona nova feature'`)
4. Faça push para a branch (`git push origin feature/nova-feature`)
5. Abra um Pull Request

## Licença

Este projeto está licenciado sob a licença MIT - veja o arquivo [LICENSE](LICENSE) para mais detalhes.

## **Writing Tests for `dadosfera-lib`**


### **General Guidelines**:

- **Using `pytest`**: All tests should be written using the `pytest` framework. It provides a lot of helpful features out-of-the-box and is the preferred testing tool for this library.

- **Using Mocks**: Whenever possible, try to use mocks in your tests. This helps in isolating the functionality and ensures that you're testing only the part of the code that you intend to.

- **Test Structure**: The structure of the tests should mirror the structure of the library. This makes it easier to locate tests and understand which parts of the codebase they correspond to.

**Example**:

If the library structure is:

```
dadosfera
├── components
│   ├── brand.py
│   ├── hamburger_menu.py
```

Then, the corresponding test structure should be:

```
tests
├── components
│   ├── test_brand.py
│   ├── test_hamburger_menu.py
```

### **`pytest` Hints**:

- **Test Functions**: Every test function should start with `test_`. This is how `pytest` recognizes which methods to run as tests. For instance: `test_function_name`.

- **Test Modules**: Similarly, modules (python files) containing tests should also start with `test_`. This allows `pytest` to recognize and collect them.

- **Fixtures**: If you're using fixtures to set up some recurring prerequisites for your tests, the fixture function should start with `fixture_` and use the `name` argument to specify a more intuitive fixture name.

    **Example**:

    ```python
    @pytest.fixture(name='database_connection')
    def fixture_database_connection():
        # setup logic
        ...
        yield connection
        # teardown logic
        ...
    ```

    When referencing the fixture in your tests, you should use its given name:

    ```python
    def test_database_functionality(database_connection):
        # Your test logic here
    ```

### **In Summary**:

When writing tests for the `dadosfera-lib`, ensure that they are clear, concise, and thoroughly cover the functionality you're testing. By following the conventions and guidelines outlined above, you'll ensure that your tests are not only effective but also well-organized and easy to navigate.

---


## Running Tests for dadosfera-lib
### Pre-requisites:
- Docker and Docker-compose should be installed on your machine.
- You should have cloned the dadosfera-lib repository to your local system.


### Instructions:

1. **Setting up Environment Variables:**

Before you can run the tests, the environment variables required for the test suite need to be set up. For your convenience, an example .env file is provided.

- Navigate to the root directory of dadosfera-lib.

- Copy test.env.example to test.env:

```bash
cp test.env.example test.env
```

- Open the test.env file with your favorite text editor. Replace <openai_api_key> with your actual OpenAI API key:
```shell
OPENAI_API_KEY=your_actual_openai_api_key
```

- Save and close the file.

2. **Building the Docker Container:**

Build the Docker container with the provided Docker configuration. From the root directory of dadosfera-lib, execute:

```bash
docker-compose -f test.local.docker-compose.yml build
```

3. **Running the Test Suite:**

After building the Docker container, run the test suite using:

```bash
docker-compose -f test.local.docker-compose.yml run test_suite
```

The tests will commence and the terminal will display the test details, indicating which are in progress and their pass/fail status.

### Notes:

- Ensure you provide a valid OpenAI API key in the test.env for successful test execution.
- The test suite operates inside a Docker container to guarantee a consistent test environment.
- Due to the utilization of Docker volumes, changes made to the code are immediately reflected inside the container. Thus, there's no need to rebuild the Docker image after every change. However, if you've added new dependencies or libraries, rebuilding the image will be necessary.