Changeset 190

Show
Ignore:
Timestamp:
08/16/08 23:44:00 (4 months ago)
Author:
rgrp
Message:

[shakespeare/tests][s]: introduce setup_class to test_text.py to ensure shakespeare texts are all loaded up before run.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/shakespeare/tests/functional/test_text.py

    Revision 157 Revision 190
    1from StringIO import StringIO 1from StringIO import StringIO 
    2 2 
      3import pkg_resources 
      4 
    3from shakespeare.tests import * 5from shakespeare.tests import * 
      6import shakespeare.model as model 
    4 7 
    5class TestTextController(TestController): 8class TestTextController(TestController): 
      9    @classmethod 
      10    def setup_class(cls): 
      11        text = model.Material.byName('tempest_gut') 
      12        if text is None: 
      13            pkg = 'shksprdata' 
      14            meta = pkg_resources.resource_stream(pkg, 'texts/metadata.txt') 
      15            model.Material.load_from_metadata(meta) 
    6 16 
    7    def test_index(self): 17    def test_index(self): 
    8        url = url_for(controller='text') 18        url = url_for(controller='text') 
    9        res = self.app.get(url) 19        res = self.app.get(url) 
    10        print res 20        print res 
    11        assert "Shakespeare's Works" in res 21        assert "Shakespeare's Works" in res 
    12        assert 'The Tempest' in res 22        assert 'The Tempest' in res 
    13 23 
    14    def test_view_1(self): 24    def test_view_1(self): 
    15        url = url_for(controller='text', action='view', name='tempest_gut', 25        url = url_for(controller='text', action='view', name='tempest_gut', 
    16            format='plain') 26            format='plain') 
    17        res = self.app.get(url) 27        res = self.app.get(url) 
    18        assert 'CALIBAN, a savage and deformed Slave' in res 28        assert 'CALIBAN, a savage and deformed Slave' in res 
    19 29 
    20    def test_index_2(self): 30    def test_index_2(self): 
    21        url = url_for(controller='text') 31        url = url_for(controller='text') 
    22        res = self.app.get(url) 32        res = self.app.get(url) 
    23        res = res.click('The Tempest', index=0) 33        res = res.click('The Tempest', index=0) 
    24        assert 'CALIBAN, a savage and deformed Slave' in res 34        assert 'CALIBAN, a savage and deformed Slave' in res 
    25 35 
    26    def test_view_2(self): 36    def test_view_2(self): 
    27        url = url_for(controller='text', action='view', 37        url = url_for(controller='text', action='view', 
    28                name=['tempest_gut','tempest_gut_f'], format='plain') 38                name=['tempest_gut','tempest_gut_f'], format='plain') 
    29        res = self.app.get(url) 39        res = self.app.get(url) 
    30        assert 'CALIBAN, a savage and deformed Slave' in res 40        assert 'CALIBAN, a savage and deformed Slave' in res 
    31 41 
    32    def test_view_3(self): 42    def test_view_3(self): 
    33        url = url_for(controller='text', action='view', 43        url = url_for(controller='text', action='view', 
    34                name=['tempest_gut', 'tempest_gut_f'], format='raw') 44                name=['tempest_gut', 'tempest_gut_f'], format='raw') 
    35        res = self.app.get(url) 45        res = self.app.get(url) 
    36        assert 'CALIBAN, a savage and deformed Slave' in res 46        assert 'CALIBAN, a savage and deformed Slave' in res 
    37 47 
    38    def test_view_with_unicode_source(self): 48    def test_view_with_unicode_source(self): 
    39        url = url_for(controller='text', action='view', 49        url = url_for(controller='text', action='view', 
    40                name='all_is_well_that_ends_well_gut_f', format='plain') 50                name='all_is_well_that_ends_well_gut_f', format='plain') 
    41        res = self.app.get(url) 51        res = self.app.get(url) 
    42        assert "All's Well, that Ends Well" in res 52        assert "All's Well, that Ends Well" in res 
    43 53