~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/browser/tests/potemplate-views.txt

Merge with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
    >>> from lp.registry.interfaces.sourcepackagename import (
15
15
    ...     ISourcePackageNameSet)
16
16
    >>> from lp.translations.publisher import TranslationsLayer
17
 
    >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
18
17
 
19
18
All the tests will be submitted as comming from the No Privilege person.
20
19
 
108
107
    >>> entry.path
109
108
    u'po/es.po'
110
109
 
111
 
Let's check the traversal code.
112
 
 
113
 
    >>> from zope.security.proxy import isinstance
114
 
    >>> from lp.translations.browser.potemplate import POTemplateNavigation
115
 
    >>> from lp.translations.model.pofile import POFile, DummyPOFile
116
 
 
117
 
First, what happens if we get any method that is not supported?
118
 
 
119
 
    >>> request = LaunchpadTestRequest()
120
 
    >>> request.method = 'PUT'
121
 
    >>> navigation = POTemplateNavigation(potemplate, request)
122
 
    >>> navigation.traverse('es')
123
 
    Traceback (most recent call last):
124
 
    ...
125
 
    AssertionError: We only know about GET, HEAD, and POST
126
 
 
127
 
But when we use a supported method, we get the right object.
128
 
 
129
 
    >>> request.method = 'GET'
130
 
    >>> isinstance(navigation.traverse('es'), POFile)
131
 
    True
132
 
 
133
 
Now, we are going to select a POFile that doesn't exist yet in our database.
134
 
 
135
 
    >>> isinstance(navigation.traverse('zh_TW'), DummyPOFile)
136
 
    True
137
 
 
138
 
But if we do a POST, instead of getting a DummyPOFile object, we will get a
139
 
POFile one.
140
 
 
141
 
    >>> request.method = 'POST'
142
 
    >>> isinstance(navigation.traverse('zh_TW'), POFile)
143
 
    True
144
 
 
145
110
And that's all, folks!