Skip to content

Commit

Permalink
Bug fix in color count writing
Browse files Browse the repository at this point in the history
-  Add changelog detail and bump package version
  • Loading branch information
MarvinKweyu committed Aug 13, 2020
1 parent 9e09f45 commit b719659
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
18 changes: 15 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
=====================
ColorDetect Changelog
=====================
.. _0.2.0:
0.2.0 (13-08-2020)
==================

Features
--------
- Enable input of custom text onto the image

Documentation
-------------

- Add ``write_text`` method along with other breaking changes to the documentation

.. _0.1.7:
0.1.7 (17-04-2020)
Expand Down Expand Up @@ -64,7 +76,7 @@ Bugfixes
Improved Documentation
----------------------

- Publish package documentation
- Publish package documentation
`ColorDetect <https://colordetect.readthedocs.io/en/latest/>`_

Misc
Expand All @@ -87,7 +99,7 @@ Features
Bug fixes
---------

- Fix image reading.
- Fix image reading.

Misc
----
Expand All @@ -107,4 +119,4 @@ Features

0.1.1 (22-03-2020)
==================
- Initial release
- Initial release
2 changes: 1 addition & 1 deletion colordetect/color_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def write_color_count(self):
-----------------
Write the number of colors found to the image
"""
line_spacing = 200
line_spacing = 0
for k, v in self.color_description.items():
color_values = str(v) + '% :' + k
self.write_text(text=color_values, line_spacing=line_spacing)
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="0.1.7",
version="0.2.0",
author="Marvin Kweyu",
author_email="mkweyu1@gmail.com",
description="Detect and recognize colors in images",
Expand Down
20 changes: 13 additions & 7 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import imghdr
from pathlib import Path
from unittest import TestCase

import pytest

from ..colordetect import ColorDetect
import matplotlib.colors as mcolors

"""
# Tests to be written:
Whether an image is loaded/present in the given folder
whether an image is loaded
test whether text is written to the image
return of correct color format
"""

Expand All @@ -20,7 +22,7 @@ def test_existence_of_image_path(image):
"""
Test whether the filename used in the test is the first image
"""
assert (Path(image).exists())
assert Path(image).exists()


def test_argument_is_image(image):
Expand All @@ -36,9 +38,9 @@ def test_image_has_been_saved(datadir, image):
"""
user_image = ColorDetect(image)
user_image.get_color_count(color_count=1)
file_name = 'out.jpg'
user_image.save_color_count(location=datadir, file_name=file_name)
assert (Path(datadir / file_name).exists())
file_name = "out.jpg"
user_image.save_image(location=datadir, file_name=file_name)
assert Path(datadir / file_name).exists()


def test_correct_color_format(image):
Expand All @@ -47,11 +49,15 @@ def test_correct_color_format(image):
:param image:
:return:
"""
pass
user_image = ColorDetect(image)
# test rgb returns rgb color format
color_codes = user_image.get_color_count(color_count=1, color_format="hex")
color_code = list(color_codes.keys())[0]
assert mcolors.is_color_like(color_code)


def test_text_in_image(datadir):
"""
output image should have text
output image should have text
"""
pass
2 changes: 1 addition & 1 deletion tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def test_result_file_name_is_valid(image, datadir):
user_image.get_color_count(color_count=1)

with pytest.raises(Exception) as e_info:
user_image.save_color_count(location=datadir, file_name=5)
user_image.save_image(location=datadir, file_name=5)

0 comments on commit b719659

Please sign in to comment.