testinggtk r195 - trunk/tests



Author: bjornl
Date: Sat Jun 21 15:48:07 2008
New Revision: 195
URL: http://svn.gnome.org/viewvc/testinggtk?rev=195&view=rev

Log:
6 tests for the gtk.RecentManager class

Added:
   trunk/tests/test_recentmanager.py

Added: trunk/tests/test_recentmanager.py
==============================================================================
--- (empty file)
+++ trunk/tests/test_recentmanager.py	Sat Jun 21 15:48:07 2008
@@ -0,0 +1,72 @@
+'''
+Tests for the ``gtk.RecentManager`` class.
+'''
+import gio
+import gtk
+import os
+
+def test_default_attributes():
+    rm = gtk.RecentManager()
+    assert rm.get_limit() == -1
+
+def test_add_full_no_mime_type():
+    '''
+    Ensure that a ``RuntimeError`` is raised when attempting to add an
+    item without a mime_type.
+    '''
+    rm = gtk.RecentManager()
+    try:
+        rm.add_full('hi', dict())
+        assert False
+    except RuntimeError:
+        assert True
+
+def test_add_full_no_app_type():
+    '''
+    Ensure that a ``RuntimeError`` is raised when attempting to add an
+    item without an app_type.
+    '''
+    rm = gtk.RecentManager()
+    try:
+        rm.add_full('hi', dict(mime_type = 'foo'))
+        assert False
+    except RuntimeError:
+        assert True
+
+def test_add_full_no_app_name():
+    '''
+    Ensure that a ``RuntimeError`` is raised when attempting to add an
+    item without an app_name attribute.
+    '''
+    rm = gtk.RecentManager()
+    try:
+        rm.add_full('hi', dict(mime_type = 'foo',
+                               app_type = 'foo'))
+        assert False
+    except RuntimeError:
+        assert True
+
+def test_add_full_no_app_exec():
+    '''
+    Ensure that a ``RuntimeError`` is raised when attempting to add an
+    item without an app_exec attribute.
+    '''
+    rm = gtk.RecentManager()
+    try:
+        rm.add_full('hi', dict(mime_type = 'foo',
+                               app_type = 'foo',
+                               app_name = 'gedit'))
+        assert False
+    except RuntimeError:
+        assert True
+
+def test_add_item():
+    rm = gtk.RecentManager()
+    file = gio.file_parse_name(__file__)
+    uri = file.get_uri()
+    assert rm.add_full(uri, dict(mime_type = 'foo',
+                                 app_type = 'foo',
+                                 app_name = 'boo',
+                                 app_exec = 'gedit'))
+    recent_info = rm.lookup_item(uri)
+    assert recent_info.get_uri() == uri



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]