-
Notifications
You must be signed in to change notification settings - Fork 63
Ajustes teste unitarios #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Ajustes teste unitarios #66
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por curiosidade, o que gerou esses folders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pode remover essa linha em branco?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pode, desculpa
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pode explicar o que aconteceu aqui? Evita o snake, estou usando o lowerUpperCase getGlobalGameCacheWindow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 usa o snake case, criei o metodo pra facilitar o mock, o mock anterior não funcionava
@@ -10,5 +12,8 @@ | |||
def test_should_get_container_bottom_bar_pos(): | |||
screenshotImage = loadFromRGBToGray(f'{currentPath}/screenshot.png') | |||
containerBottomBarPos = getContainerBottomBarPosition(screenshotImage) | |||
expectedContainerBottomBarPos = (1748, 621, 156, 4) | |||
# save for conference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove o comentário
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qual a idéia aqui?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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), | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qual a idéia aqui?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não versiona isso
SonarCloud Quality Gate failed.
|