Changeset 2371 in products


Ignore:
Timestamp:
May 21, 2010 11:10:30 AM (14 years ago)
Author:
mylan
Message:

Updated tests with new converter by property functionality, fixed bug in converter

Location:
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/tests.py

    r2370 r2371  
    301301        return "http://nohost/plone" 
    302302    def getRelativeContentPath(self, context): 
    303         return "/plone/" + context.getId() 
     303        return ("plone", context.getId()) 
    304304 
    305305class BaseItem: 
     
    333333        item._setProperty(PROPERTY_PATH, "/www/some/path") 
    334334        self.convertor.convertIPathToLink(item) 
     335        # 1. check canonical link in result object 
    335336        result = ICanonicalLink(item).canonical_link 
    336337        expect = "http://domain.com/www/some/path" 
    337338        self.assertEqual(result, expect, "Got %s canonical link, " \ 
    338339                         "expect: %s" % (result, expect)) 
    339          
     340        # 2. canonical path propery mast be delete from the object 
     341        self.assertEqual(item.hasProperty(ICanonicalPath(item).prop), False, 
     342                         "canonical path' property not deleted from the object") 
     343 
     344    def test_convertPPathToLink(self): 
     345        item = GoodItem("item") 
     346        item._setProperty("custom_property", "/www/some/path") 
     347        self.convertor.convertPPathToLink(item, prop="custom_property") 
     348        # 1. check canonical link in result object 
     349        result = ICanonicalLink(item).canonical_link 
     350        expect = "http://domain.com/www/some/path" 
     351        self.assertEqual(result, expect, "Got %s canonical link, " \ 
     352                         "expect: %s" % (result, expect)) 
     353        # 2. custom_property mast be deleted from the object 
     354        self.assertEqual(item.hasProperty("custom_property"), False, 
     355                         "custom_property not deleted from the object") 
     356 
    340357    def test_convertBadItems(self): 
    341358        bad = NotProperyProviderItem("item") 
     
    383400        self.assertEqual(logs, "", "Log not cleand-up: \"%s\"" % logs) 
    384401 
    385   
     402 
    386403def test_suite(): 
    387404    return unittest.TestSuite([ 
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/upgrades.py

    r2370 r2371  
    2525        self.portal_url = portal_url 
    2626 
     27    # General APIs 
    2728    def getLogs(self): 
    2829        self._inout.flush() 
     
    5657                             self._convertP2L) 
    5758 
     59    # Service methods 
    5860    def _convert(self, obj, src_iface, dst_iface, converter): 
    5961        """Convert canonical from source canonical interface 
     
    9294        if type(arg) in StringTypes: 
    9395            adapter = DefaultPropertyAdapter(obj) 
    94             adapater.prop = arg 
     96            adapter.prop = arg 
    9597            return adapter 
    9698        else: 
Note: See TracChangeset for help on using the changeset viewer.