Conversation
engFelipeMonteiro
commented
May 31, 2023
- Ajustes teste unitarios
- Funcáo pra salvar resultado de teste unitario
- Ajustes macos - Funcáo pra salvar resultado de teste unitario
|
Aguardar validação |
| env39 | ||
| tests/validation_images/*.png No newline at end of file |
There was a problem hiding this comment.
Por curiosidade, o que gerou esses folders?
There was a problem hiding this comment.
env39/
pasta do venv que criei dentro da pasta.
Fiz um metodo pra criar imagens desenhando um quadrado na parte selecinada baseado na posição recebida pelos metodos, pra validação visual dos metodos
tests/validation_images/*.png
| @@ -1,13 +1,19 @@ | |||
| from typing import Tuple, Union | |||
| from typing import Tuple, Union, Dict | |||
There was a problem hiding this comment.
Eu sugeria eu ordenar os imports para ficar mais organizado:
| from typing import Tuple, Union, Dict | |
| from typing import Dict, Tuple, Union |
|
|
||
| import pyautogui | ||
| import cv2 | ||
| import numpy as np | ||
|
|
||
| class PyCamera(): | ||
| is_capturing = True | ||
|
|
||
| def get_latest_frame(self, path='screen.png'): | ||
| img = pyautogui.screenshot() | ||
| img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2GRAY) | ||
| if path: | ||
| # import cv2; cv2.imwrite('screen_test.png', screenshot) | ||
| cv2.imwrite(path, img) | ||
| return img | ||
|
No newline at end of file |
There was a problem hiding this comment.
Seria legal criar uma classe com Polimorfismo para decidir qual SO usar e qual lib usar.
o DxCam serve para o windows, dxlib serve para linux, tb deve ser para mac, que tal tentar? Performance interessa muito nesse projeto.
| @@ -1,3 +1,4 @@ | |||
|
|
|||
There was a problem hiding this comment.
Pode remover essa linha em branco?
| def get_global_game_cache_window_cache() -> Dict: | ||
| """ | ||
| function to ease mocking the cache | ||
| """ | ||
| global gameWindowCache | ||
| return gameWindowCache |
There was a problem hiding this comment.
Pode explicar o que aconteceu aqui? Evita o snake, estou usando o lowerUpperCase getGlobalGameCacheWindow
There was a problem hiding this comment.
flake8 usa o snake case, criei o metodo pra facilitar o mock, o mock anterior não funcionava
| screenshotImage = loadFromRGBToGray(f'{currentPath}/screenshot.png') | ||
| containerBottomBarPos = getContainerBottomBarPosition(screenshotImage) | ||
| expectedContainerBottomBarPos = (1748, 621, 156, 4) | ||
| # save for conference |
| import pathlib | ||
| import cv2 | ||
| import numpy as np | ||
| import pytest | ||
|
|
||
| from src.repositories.gameWindow.core import getLeftArrowPosition, getRightArrowPosition | ||
|
|
||
| from tests.utils import result_pos_draw |
There was a problem hiding this comment.
| import pathlib | |
| import cv2 | |
| import numpy as np | |
| import pytest | |
| from src.repositories.gameWindow.core import getLeftArrowPosition, getRightArrowPosition | |
| from tests.utils import result_pos_draw | |
| import cv2 | |
| import numpy as np | |
| import pathlib | |
| import pytest | |
| from src.repositories.gameWindow.core import getLeftArrowPosition, getRightArrowPosition | |
| from tests.utils import result_pos_draw |
| @pytest.mark.parametrize("img, is_gray", [ | ||
| (img01, False), | ||
| (img02_gray, True), | ||
| (img03, False), | ||
| (img04, False), | ||
| ]) |
There was a problem hiding this comment.
usar diversas imagens como input do teste unitario, sendo alguns 1920X1080 e outras resolução mac os(16:10)
| @pytest.mark.parametrize("img, is_gray", [ | ||
| (img01, False), | ||
| (img02_gray, True), | ||
| (img03, False), | ||
| ]) |
|
SonarCloud Quality Gate failed.
|









