Skip to content

Commit

Permalink
Basic icon module tests
Browse files Browse the repository at this point in the history
Calling `get_from_name()` with no parameters, should return the pixbuf
object through `load_icon()` and default parameters.
  • Loading branch information
AndreMiras committed Dec 21, 2019
1 parent ddcca32 commit 495a356
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lxml
coveralls
mock
22 changes: 22 additions & 0 deletions tests/utils/test_icon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import unittest
import mock

from gi.repository import GdkPixbuf
from ubuntucleaner.utils.icon import get_from_name, DEFAULT_SIZE


class TestIconModule(unittest.TestCase):

def test_get_from_name(self):
"""
Calling with no parameters should return the pixbuf object through `load_icon()`
and default parameters.
"""
m_pixbuf = mock.Mock(spec=GdkPixbuf.Pixbuf, get_height=lambda: DEFAULT_SIZE)
with mock.patch("ubuntucleaner.utils.icon.Gtk.IconTheme.load_icon") as m_load_icon:
m_load_icon.return_value = m_pixbuf
pixbuf = get_from_name()
self.assertEqual(
m_load_icon.call_args_list, [mock.call("gtk-execute", 24, 0)]
)
self.assertEqual(pixbuf, m_pixbuf)

0 comments on commit 495a356

Please sign in to comment.