Skip to content

Commit e2de4ca

Browse files
committed
Adding test cases for the class DiffMotionDetector in the motion_detection.py file
1 parent fddc129 commit e2de4ca

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

deepgaze/background.jpg

945 KB
Loading

deepgaze/foreground.jpg

945 KB
Loading

deepgaze/test.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
# Generated by CodiumAI
3+
from deepgaze.deepgaze.motion_detection import DiffMotionDetector
4+
import cv2
5+
6+
7+
import pytest
8+
9+
class TestDiffMotionDetector:
10+
11+
# Tests that the background image is set successfully
12+
def test_set_background_successfully(self):
13+
detector = DiffMotionDetector()
14+
background_image = cv2.imread('background.jpg')
15+
detector.setBackground(background_image)
16+
assert detector.getBackground() is not None
17+
18+
# Tests that a binary image is returned successfully after the detection process
19+
def test_return_binary_image_successfully(self):
20+
detector = DiffMotionDetector()
21+
background_image = cv2.imread('background.jpg')
22+
foreground_image = cv2.imread('foreground.jpg')
23+
detector.setBackground(background_image)
24+
binary_image = detector.returnMask(foreground_image)
25+
assert binary_image is not None
26+
27+
# Tests that a background image is set and a binary image is returned successfully after the detection process
28+
def test_set_background_and_return_binary_image_successfully(self):
29+
detector = DiffMotionDetector()
30+
background_image = cv2.imread('background.jpg')
31+
foreground_image = cv2.imread('foreground.jpg')
32+
detector.setBackground(background_image)
33+
binary_image = detector.returnMask(foreground_image)
34+
assert detector.getBackground() is not None and binary_image is not None
35+
36+
# Tests that setting a None background image returns None
37+
def test_set_none_background_image_and_return_none(self):
38+
detector = DiffMotionDetector()
39+
detector.setBackground(None)
40+
assert detector.getBackground() is None
41+
42+
# Tests that setting a None foreground image returns None
43+
def test_set_none_foreground_image_and_return_none(self):
44+
detector = DiffMotionDetector()
45+
background_image = cv2.imread('background.jpg')
46+
detector.setBackground(background_image)
47+
binary_image = detector.returnMask(None)
48+
assert binary_image is None
49+
50+
# Tests that setting a None background image returns None after the detection process
51+
def test_set_none_background_image_and_return_none_after_detection_process(self):
52+
detector = DiffMotionDetector()
53+
detector.setBackground(None)
54+
assert detector.getBackground() is None

0 commit comments

Comments
 (0)