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' )
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'],])
def test_empty_cos_of_dodgy_characters(self): with ShouldRaise(ValueError('The name must not be empty')): make_name(self.context,'$%')
def test_empty(self): with ShouldRaise(ValueError('The name must not be empty')): make_name(self.context,'')
def test_complex(self): self.assertEqual( make_name(self.context,'$%^some thing'), 'some-thing' )
def test_simple(self): self.assertEqual( make_name(self.context,'something'), 'something' )