-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🤡 fakers: add base * 🤡 fakers: add plants * 🤡 fakers: add users * 📑 interfaces: add users repository * 📑 interfaces: add plants repository * 🏭 factories: add update active plant * 🏭 factories: add filters plants use case * 🏭 factories: add create plant by form use case * 🏭 factories: add delete plant use case * 🏭 factories: add get plant by id factory use case * 🏭 factories: add get plants page data use case * 🏭 factories: add update plant use case * 🤡 mocks: add plants repository * 🤡 mocks: add users repositories * 🧪 tests: update active plant * 🧪 tests: create plant by form use case * 🧪 tests: get plants page data use case * 🧪 tests: delete plant use case * 🧪 tests: update plant use case * 🧪 tests: filter plants use case * 🧪 tests: get plant by id use case * 🚨 errors: pass ui message to super error * ♻️ refactor: use factory pattern upon plants use cases * 🚨 errors: add base error * 🚨 errors: add email template not provided error * 🚨 errors: incorrect admin user email error * 🚨 errors: add sender password not provided error * 🚨 errors: add user email not provided error * 📑 providers: add email provider * 📑 interfaces: add auth * 🏭 factories: add auth * 🤡 mocks: add auth * 🤡 mocks: add email provider * 🧪 tests: login user * 🧪 tests: reset password use case * 🧪 tests: request password reset use case * ♻️ refactor: all custom errors implamentations and usage * 🧪 tests: weekday common * 🧪 tests: csv file common * 🧪 tests: date common * 🧪 tests: days range common * 🧪 tests: weekday common * 🚨 errors: add datime not valid error * 🚨 errors: add date not valid error * 🧪 tests: ordered plants common * 🧪 tests: records filters common * 🧪 tests: datetime common * 📑 interfaces: add data analyser provider * 🚨 errors: add csv file validation * 👥 entities: add line chart record * 🥸 fakers: add sensors records * 🥸 fakers: add line chart records * 🧪 tests: line chart common * 📦 deps: install dependencies for tests * ⚙️ config: set env vars for test enviroment * 🧩 commons: enhance date and datime validation * 🚨 errors: add for sensors records * 🏷️ types: add hints for each attribute of error classes * 🧩 commons: use date value on set records filters * 💾 database: prevent mysql from starting under test enviroment * 🤡 mocks: add sensors records repository * 📑 interfaces: add sensors records repository * ⚡perf: remove useless logs from app * 🧪 tests: create sensors record by api use case * 🧪 tests: create sensors record by csv file use case * 🧪 tests: create sensors records by form use case * 🧪 tests: get sensors records dashboard page data use case * 🧪 tests: delete sensors records use case * 🧪 tests: get sensors records csv file use case * 🧪 tests: get last record page data use case * 🧪 tests: ge sensors records csv file use case * 🏭 factories: add create sensors record by api use case * 🏭 factories: add all sensors records use cases * 🚨 errors: add page number * 🧪 tests: pagination common * 🐛 fix: sensors records use cases exportations * 🧩 commons: get date on get records filters date values * 🥸 fakers: add checklist records * 🚨 errors: add checklist record not valid * 🚨 errors: add hour not valid * 🚨 errors: add checklist record not found * 📑 interfaces: add checklist records repository * 🧪 tests: create checklist record by csv file use case * 🧪 tests: create checklist record by csv form use case * 🧪 tests: create delete checklist record use case * 🧪 tests: create get checklist records csv file use case * 🧪 tests: get checklist records table page data use case * 🧪 tests: update checklist record use case * 🤡 mocks: add checklist records repository * 🏭 factories: checklist records use cases * 🧪 tests: fix line chart common * 🏭 factories: sensors records use cases * 🤡 mocks: add csv_file_attribute to data analyser provider * 🚄 ci: run core tests on every push or pull request * 🐛 fix: sensors records counting with filters * 🐛 fix: delete many records using mysql conector * ♻️ refactor: sensors records and checklist records views making them to use use cases from factories * 🤡 mocks: fix get sensors records count params of sensors records repository
- Loading branch information
1 parent
946ce10
commit 8594e30
Showing
226 changed files
with
6,109 additions
and
1,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Continuous Integration | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
CI: | ||
name: Run core tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Init job | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.10.12 | ||
cache: 'pip' | ||
|
||
- name: Install Python dependencies | ||
run: pip install -r requirements.txt | ||
|
||
- name: Run core tests | ||
run: python -m pytest src/app/core | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
[tool.ruff] | ||
ignore = [ | ||
"F403" # undefined-names, | ||
] | ||
|
||
[tool.pytest.ini_options] | ||
env = [ | ||
"ENVIRONMENT=test" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,50 @@ | ||
from typing import Dict, List | ||
from werkzeug.datastructures import FileStorage | ||
|
||
from core.commons import Error | ||
|
||
from infra.providers.data_analyser_provider import DataAnalyserProvider | ||
from core.interfaces.providers import DataAnalyserProviderInterface | ||
from core.errors.validation import CSVFileNotValidError, CSVColumnsNotValidError | ||
|
||
|
||
class CsvFile: | ||
def __init__(self, csv_file: FileStorage) -> None: | ||
self.csv_file = csv_file | ||
self.data_analyser_provider = DataAnalyserProvider() | ||
def __init__( | ||
self, | ||
file: FileStorage, | ||
data_analyser_provider: DataAnalyserProviderInterface, | ||
): | ||
if not isinstance(file, FileStorage): | ||
raise CSVFileNotValidError() | ||
|
||
self._file = file | ||
self._data_analyser_provider = data_analyser_provider | ||
|
||
def read(self): | ||
extension = self.get_extension() | ||
extension = self.__get_extension() | ||
|
||
if extension in ["csv", "txt"]: | ||
self.data_analyser_provider.read_csv(self.csv_file) | ||
self._data_analyser_provider.read_csv(self._file) | ||
elif extension == "xlsx": | ||
self.data_analyser_provider.read_excel(self.csv_file) | ||
self._data_analyser_provider.read_excel(self._file) | ||
else: | ||
raise Error("Arquivo CSV inválido") | ||
raise CSVFileNotValidError() | ||
|
||
def get_records(self) -> List[Dict]: | ||
records = self.data_analyser_provider.convert_to_list_of_records() | ||
records = self._data_analyser_provider.convert_to_list_of_records() | ||
|
||
records_list = [] | ||
for record in records: | ||
records_list.append({key.lower(): value for key, value in record.items()}) | ||
|
||
return records_list | ||
|
||
def validate_columns(self, columns: List[str]) -> bool: | ||
csv_columns = self.data_analyser_provider.get_columns() | ||
def validate_columns(self, columns: List[str]): | ||
csv_columns = self._data_analyser_provider.get_columns() | ||
|
||
has_valid_columns = set(map(lambda x: x.lower(), csv_columns)) == set( | ||
map(lambda x: x.lower(), columns) | ||
) | ||
|
||
if not has_valid_columns: | ||
raise Error("As colunas do arquivo CSV não estão corretas") | ||
raise CSVColumnsNotValidError() | ||
|
||
def get_extension(self) -> str: | ||
return self.csv_file.filename.split(".")[1] | ||
def __get_extension(self) -> str: | ||
return self._file.filename.split(".")[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.