| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | import unittest |
|---|
| 3 | from plone.registry import Registry |
|---|
| 4 | |
|---|
| 5 | from base import TestCase |
|---|
| 6 | from base import IPREFIX |
|---|
| 7 | |
|---|
| 8 | from Products.CMFCore.utils import getToolByName |
|---|
| 9 | from quintagroup.dropdownmenu.interfaces import IDropDownMenuSettings |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | class RegistryTest(TestCase): |
|---|
| 13 | |
|---|
| 14 | def afterSetUp(self): |
|---|
| 15 | # Set up the registry |
|---|
| 16 | super(RegistryTest, self).afterSetUp() |
|---|
| 17 | self.registry = Registry() |
|---|
| 18 | self.registry.registerInterface(IDropDownMenuSettings) |
|---|
| 19 | |
|---|
| 20 | def test_dropdownmenu_in_controlpanel(self): |
|---|
| 21 | # Check if dropdownmenu is in the control panel |
|---|
| 22 | self.controlpanel = getToolByName(self.portal, "portal_controlpanel") |
|---|
| 23 | self.failUnless('dropdownmenu' in [ |
|---|
| 24 | a.getAction(self)['id'] |
|---|
| 25 | for a in self.controlpanel.listActions()]) |
|---|
| 26 | |
|---|
| 27 | def test_show_icons(self): |
|---|
| 28 | # Check show_icons record |
|---|
| 29 | self.registry.records[IPREFIX + 'show_icons'] |
|---|
| 30 | |
|---|
| 31 | self.failUnless('show_icons' in IDropDownMenuSettings) |
|---|
| 32 | self.assertEquals(self.registry[IPREFIX + 'show_icons'], False) |
|---|
| 33 | |
|---|
| 34 | def test_show_content_tabs(self): |
|---|
| 35 | # Check show_content_tabs record |
|---|
| 36 | self.registry.records[IPREFIX + 'show_content_tabs'] |
|---|
| 37 | |
|---|
| 38 | self.failUnless('show_content_tabs' in IDropDownMenuSettings) |
|---|
| 39 | self.assertEquals(self.registry[IPREFIX + 'show_content_tabs'], True) |
|---|
| 40 | |
|---|
| 41 | def test_show_nonfolderish_tabs(self): |
|---|
| 42 | # Check show_nonfolderish_tabs record |
|---|
| 43 | self.registry.records[IPREFIX + 'show_nonfolderish_tabs'] |
|---|
| 44 | |
|---|
| 45 | self.failUnless('show_nonfolderish_tabs' in IDropDownMenuSettings) |
|---|
| 46 | self.assertEquals(self.registry[IPREFIX + 'show_nonfolderish_tabs'], |
|---|
| 47 | True) |
|---|
| 48 | |
|---|
| 49 | def test_content_before_actions_tabs(self): |
|---|
| 50 | # Check content_before_actions_tabs record |
|---|
| 51 | self.registry.records[IPREFIX + 'content_before_actions_tabs'] |
|---|
| 52 | |
|---|
| 53 | self.failUnless('content_before_actions_tabs' in IDropDownMenuSettings) |
|---|
| 54 | self.assertEquals(self.registry[ |
|---|
| 55 | IPREFIX + 'content_before_actions_tabs'], False) |
|---|
| 56 | |
|---|
| 57 | def test_content_tabs_level(self): |
|---|
| 58 | # Check content_tabs_level record |
|---|
| 59 | self.registry.records[IPREFIX + 'content_tabs_level'] |
|---|
| 60 | |
|---|
| 61 | self.failUnless('content_tabs_level' in IDropDownMenuSettings) |
|---|
| 62 | self.assertEquals(self.registry[IPREFIX + 'content_tabs_level'], 0) |
|---|
| 63 | |
|---|
| 64 | def test_show_actions_tabs(self): |
|---|
| 65 | # Check show_actions_tabs record |
|---|
| 66 | self.registry.records[IPREFIX + 'show_actions_tabs'] |
|---|
| 67 | |
|---|
| 68 | self.failUnless('show_actions_tabs' in IDropDownMenuSettings) |
|---|
| 69 | self.assertEquals(self.registry[IPREFIX + 'show_actions_tabs'], True) |
|---|
| 70 | |
|---|
| 71 | def test_actions_tabs_level(self): |
|---|
| 72 | # Check actions_tabs_level record |
|---|
| 73 | self.registry.records[IPREFIX + 'actions_tabs_level'] |
|---|
| 74 | |
|---|
| 75 | self.failUnless('actions_tabs_level' in IDropDownMenuSettings) |
|---|
| 76 | self.assertEquals(self.registry[IPREFIX + 'actions_tabs_level'], 0) |
|---|
| 77 | |
|---|
| 78 | def test_actions_category(self): |
|---|
| 79 | # Check actions_category record |
|---|
| 80 | self.registry.records[IPREFIX + 'actions_category'] |
|---|
| 81 | |
|---|
| 82 | self.failUnless('actions_category' in IDropDownMenuSettings) |
|---|
| 83 | self.assertEquals(self.registry[IPREFIX + 'actions_category'], |
|---|
| 84 | u"portal_tabs") |
|---|
| 85 | |
|---|
| 86 | def test_nested_category_prefix(self): |
|---|
| 87 | # Check nested_category_prefix record |
|---|
| 88 | self.registry.records[IPREFIX + 'nested_category_prefix'] |
|---|
| 89 | |
|---|
| 90 | self.failUnless('nested_category_prefix' in IDropDownMenuSettings) |
|---|
| 91 | self.assertEquals(self.registry[IPREFIX + 'nested_category_prefix'], |
|---|
| 92 | u"") |
|---|
| 93 | |
|---|
| 94 | def test_nested_category_sufix(self): |
|---|
| 95 | # Check nested_category_sufix record |
|---|
| 96 | self.registry.records[IPREFIX + 'nested_category_sufix'] |
|---|
| 97 | |
|---|
| 98 | self.failUnless('nested_category_sufix' in IDropDownMenuSettings) |
|---|
| 99 | self.assertEquals(self.registry[IPREFIX + 'nested_category_sufix'], |
|---|
| 100 | u"_sub") |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | def test_suite(): |
|---|
| 104 | return unittest.defaultTestLoader.loadTestsFromName(__name__) |
|---|