Exemplo n.º 1
0
    def test_folder_removed_when_attachments_added(self):
        " EmptyDir's shouldn't exist if there are attachments inside the 'dir' "
        addon = Package.objects.create(author=self.author, type='a')
        revision = addon.latest

        folder = EmptyDir.objects.create(name=self.path,
                                         author=self.author,
                                         root_dir='d')
        revision.folder_add(folder)
        self.assertEqual(1, revision.folders.count())

        att = Attachment(filename='/'.join([self.path, 'helpers']),
                         author=self.author,
                         ext='js')
        att.save()
        revision.attachment_add(att)
        self.assertEqual(0, revision.folders.count())

        att = Attachment(filename='model', author=self.author, ext='html')
        att.save()
        revision.attachment_add(att)
        self.assertEqual(0, revision.folders.count())
Exemplo n.º 2
0
    def test_folder_added_when_attachments_removed(self):
        " EmptyDir's should be added if all attachments in a 'dir' are removed "
        addon = Package(author=self.author, type='a')
        addon.save()
        revision = PackageRevision.objects.filter(package__name=addon.name)[0]

        att = Attachment(filename='/'.join([self.path, 'helpers']),
                         author=self.author,
                         ext='js')
        att.save()
        revision.attachment_add(att)
        self.assertEqual(0, revision.folders.count())

        revision.attachment_remove(att)
        self.assertEqual(1, revision.folders.count())
        self.assertEqual(self.path, revision.folders.all()[0].name)