示例#1
0
 def test_exists_two(self):
     self.context['name']=testing.DummyModel()
     self.context['name-2']=testing.DummyModel()
     self.assertEqual(
         make_name(self.context,'name'),
         'name-3'
         )
示例#2
0
    def relocate(match):
        matchdict = match.groupdict()
        tempid = matchdict['tempid']
        if tempid in relocated_images:
            # Already relocated this one
            url = relocated_images[tempid]
        else:
            # Move temp image to attachments folder
            image = tempfolder[tempid]
            del tempfolder[tempid]
            name = make_name(attachments, image.filename)
            attachments[name] = image
            size = (int(matchdict['width']), int(matchdict['height']))
            url = thumb_url(image, request, size)
            relocated_images[tempid] = url
            workflow = get_workflow(ICommunityFile, 'security', image)
            if workflow is not None:
                workflow.initialize(image)

        return ''.join([matchdict['pre'], url, matchdict['post'],])
示例#3
0
 def test_empty_cos_of_dodgy_characters(self):
     with ShouldRaise(ValueError('The name must not be empty')):
         make_name(self.context,'$%')
示例#4
0
 def test_empty(self):
     with ShouldRaise(ValueError('The name must not be empty')):
         make_name(self.context,'')
示例#5
0
 def test_complex(self):
     self.assertEqual(
         make_name(self.context,'$%^some thing'),
         'some-thing'
         )
示例#6
0
 def test_simple(self):
     self.assertEqual(
         make_name(self.context,'something'),
         'something'
         )