~divmod-dev/divmod.org/uneditable-contact-type-2513

« back to all changes in this revision

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

  • Committer: exarkun
  • Date: 2008-02-08 14:07:46 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:14905
Merge stylesheet-2491

Author: exarkun
Reviewer: pjd
Fixes #2491

Use the stylesheetLocation feature of XHTMLDirectoryTheme in Quotient and Hyperbola.
Also add a generic test mixin which defines a unit test for any application code
using this feature.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""
 
3
Test utilities providing coverage for implementations of Mantissa interfaces.
 
4
"""
 
5
 
 
6
from epsilon.descriptor import requiredAttribute
 
7
 
 
8
from xmantissa.webtheme import XHTMLDirectoryTheme
 
9
 
 
10
 
 
11
class XHTMLDirectoryThemeTestsMixin:
 
12
    """
 
13
    Mixin defining tests for themes based on L{XHTMLDirectoryTheme}.
 
14
 
 
15
    Mix this in to a L{twisted.trial.unittest.TestCase} and set C{theme} and
 
16
    C{offering}.
 
17
 
 
18
    @ivar theme: An instance of the theme to be tested.  Set this.
 
19
    @ivar offering: The offering which includes the theme.  Set this.
 
20
    """
 
21
    theme = requiredAttribute('theme')
 
22
    offering = requiredAttribute('offering')
 
23
 
 
24
    def test_stylesheet(self):
 
25
        """
 
26
        The C{stylesheetLocation} of the theme being tested identifies an
 
27
        existing file beneath the offering's static content path.
 
28
        """
 
29
        self.assertTrue(isinstance(self.theme, XHTMLDirectoryTheme))
 
30
        self.assertEqual(self.theme.stylesheetLocation[0], 'static')
 
31
        self.assertEqual(self.theme.stylesheetLocation[1], self.offering.name)
 
32
        path = self.offering.staticContentPath
 
33
        for segment in self.theme.stylesheetLocation[2:]:
 
34
            path = path.child(segment)
 
35
        self.assertTrue(path.exists(),
 
36
                        "Indicated stylesheet %r does not exist" % (path,))
 
37
 
 
38
 
 
39