Skip to content
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

Ajustes teste unitarios #66

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

engFelipeMonteiro
Copy link

  • Ajustes teste unitarios
  • Funcáo pra salvar resultado de teste unitario

- Ajustes macos
- Funcáo pra salvar resultado de teste unitario
@engFelipeMonteiro
Copy link
Author

Aguardar validação

@engFelipeMonteiro
Copy link
Author

todos os testes unitarios passando
image

Comment on lines +30 to +31
env39
tests/validation_images/*.png
Copy link
Owner

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?

Copy link
Author

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
Copy link
Owner

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:

Suggested change
from typing import Tuple, Union, Dict
from typing import Dict, Tuple, Union

Comment on lines +1 to +16

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

Copy link
Owner

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 @@

Copy link
Owner

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?

Copy link
Author

Choose a reason for hiding this comment

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

pode, desculpa

Comment on lines +6 to +11
def get_global_game_cache_window_cache() -> Dict:
"""
function to ease mocking the cache
"""
global gameWindowCache
return gameWindowCache
Copy link
Owner

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

Copy link
Author

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
Copy link
Owner

Choose a reason for hiding this comment

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

Remove o comentário

Comment on lines +1 to +8
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
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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

Comment on lines +26 to +31
@pytest.mark.parametrize("img, is_gray", [
(img01, False),
(img02_gray, True),
(img03, False),
(img04, False),
])
Copy link
Owner

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?

Copy link
Author

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)

Comment on lines +46 to +50
@pytest.mark.parametrize("img, is_gray", [
(img01, False),
(img02_gray, True),
(img03, False),
])
Copy link
Owner

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?

Copy link
Owner

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
Copy link

sonarcloud bot commented Jun 8, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 17 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

None yet

2 participants