Changeset 9724
- Timestamp:
- May 19, 2010, 10:12:55 PM (14 years ago)
- Location:
- trunk/trac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/trac/attachment.py
r9720 r9724 595 595 return _("Attachments of %(parent)s", 596 596 parent=get_resource_name(self.env, resource.parent)) 597 598 def resource_exists(self, resource): 599 try: 600 attachment = Attachment(self.env, resource) 601 return os.path.exists(attachment.path) 602 except ResourceNotFound: 603 return False 597 604 598 605 # Internal methods … … 977 984 finally: 978 985 input.close() 986 -
trunk/trac/tests/attachment.py
r9362 r9724 10 10 from trac.core import Component, implements 11 11 from trac.perm import IPermissionPolicy, PermissionCache 12 from trac.resource import resource_exists 12 13 from trac.test import EnvironmentStub 13 14 … … 156 157 self.assert_('ATTACHMENT_VIEW' in self.perm(attachment.resource)) 157 158 159 def test_resource_doesnt_exists(self): 160 r = Resource('wiki', 'WikiStart').child('attachment', 'file.txt') 161 self.assertEqual(False, AttachmentModule(self.env).resource_exists(r)) 162 163 def test_resource_doesnt_exists(self): 164 att = Attachment(self.env, 'wiki', 'WikiStart') 165 att.insert('file.txt', StringIO(''), 1) 166 self.assertTrue(resource_exists(self.env, att.resource)) 167 168 158 169 159 170 def suite():
Note:
See TracChangeset
for help on using the changeset viewer.