Skip to content

Commit

Permalink
fix: correct validation on font color expected output
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinKweyu committed Mar 29, 2021
1 parent f3b992b commit 29fd4e0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
14 changes: 13 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ ColorDetect Changelog
=====================




.. _1.4.3:
1.4.3 (03-29-2021)
==================

Bug Fixes
---------

- Validate RGB font color input and add tests for it


.. _1.4.2:
1.4.2 (03-09-2021)
====================
==================

Bug Fixes
---------
Expand Down
2 changes: 1 addition & 1 deletion colordetect/color_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _validate_rgb(self, rgb_tuple: tuple) -> bool:
color_range = []

for color in rgb_tuple:
if color in range(0, 255):
if color in range(0, 256):
color_range.append(True)
else:
color_range.append(False)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "Marvin Kweyu"

# The full version, including alpha/beta/rc tags
release = "1.4.2"
release = "1.4.3"

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="ColorDetect",
version="1.4.2",
version="1.4.3",
author="Marvin Kweyu",
author_email="mkweyu1@gmail.com",
description="Detect and recognize colors in images or video",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,12 @@ def test_ordered_colors_are_correct_count(video):
hence two consecutive calls might grab diff frames on the same second
"""
# assert list(dominant_colors.values()) == [68.83, 22.48, 22.22, 21.7, 19.11, 17.77]

def test_validation_of_rgb_is_correct(image):
"""
test a valid rgb format can be identified
"""
user_image = ColorDetect(image)
assert user_image._validate_rgb((255,0,0)) == True
assert user_image._validate_rgb((256,0,0)) == False
assert user_image._validate_rgb((255,-2,0)) == False

0 comments on commit 29fd4e0

Please sign in to comment.