~divmod-dev/divmod.org/lsbranch-1195

« back to all changes in this revision

Viewing changes to Mantissa/xmantissa/test/test_theme.py

  • Committer: glyph
  • Date: 2007-12-03 04:10:23 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:14436
Re-merge site-store theme changes after correcting for a poorly-written test.

Author: glyph

Reviewer: moe

Fixes #2413

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
from twisted.trial.unittest import TestCase
6
6
from twisted.python.reflect import qual
7
7
from twisted.python.util import sibpath
 
8
from twisted.python.filepath import FilePath
8
9
 
9
10
from nevow.athena import LivePage
10
11
from nevow.loaders import stan, xmlstr
26
27
from xmantissa.ixmantissa import ITemplateNameResolver
27
28
from xmantissa.port import TCPPort
28
29
from xmantissa import webtheme
29
 
from xmantissa.ixmantissa import ITemplateNameResolver
30
30
from xmantissa.webtheme import (
31
 
    getAllThemes, getInstalledThemes, MantissaTheme, ThemedFragment,
32
 
    ThemedElement, _ThemedMixin, ThemedDocumentFactory)
 
31
    getInstalledThemes, MantissaTheme, ThemedFragment,
 
32
    ThemedElement, _ThemedMixin, ThemedDocumentFactory,
 
33
    SiteTemplateResolver)
33
34
from xmantissa.website import WebSite
34
35
from xmantissa.offering import installOffering
35
36
from xmantissa.plugins.baseoff import baseOffering
36
 
from zope.interface import implements
37
37
 
38
38
from xmantissa.publicweb import PublicAthenaLivePage
39
39
from xmantissa.webapp import (GenericNavigationAthenaPage, _PageComponents,
501
501
 
502
502
 
503
503
 
 
504
class TestSiteTemplateResolver(TestCase):
 
505
    """
 
506
    Tests for L{SiteTemplateResolver}
 
507
    """
 
508
 
 
509
    def test_getDocFactory(self):
 
510
        """
 
511
        L{SiteTemplateResolver.getDocFactory} should return only installed
 
512
        themes for its store.
 
513
        """
 
514
        s = Store()
 
515
        siteResolver = SiteTemplateResolver(s)
 
516
        self.assertEqual(siteResolver.getDocFactory('shell'), None)
 
517
        installOffering(s, baseOffering, {})
 
518
        resolvedTemplate = siteResolver.getDocFactory('shell')
 
519
        # Note: nevow doesn't *really* have a stable white-box API for
 
520
        # determining the template's path, but this is close enough, since we
 
521
        # should only construct these one way (without using the lame-o
 
522
        # templateDir feature).
 
523
        # but let's sanity check just to be sure.
 
524
        self.assertIdentical(resolvedTemplate.templateDir, None)
 
525
        foundPath = FilePath(resolvedTemplate.template)
 
526
        expectedPath = FilePath(
 
527
            baseOffering.themes[0].directoryName).child(
 
528
            'shell.html')
 
529
        self.assertEqual(foundPath, expectedPath)
 
530
 
 
531
 
 
532
 
504
533
class TestThemeCache(TestCase):
505
534
    """
506
535
    some tests for L{ThemeCache}.