def test_image_deleted_after_update(organisation_factory, ImagePNG): organisation = organisation_factory(image=ImagePNG, logo=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, organisation.image.path) logo_path = os.path.join(settings.MEDIA_ROOT, organisation.logo.path) thumbnail_image_path = helpers.createThumbnail(organisation.image) thumbnail_logo_path = helpers.createThumbnail(organisation.logo) assert os.path.isfile(thumbnail_image_path) assert os.path.isfile(thumbnail_logo_path) assert os.path.isfile(image_path) assert os.path.isfile(logo_path) new_image_path = os.path.join( settings.MEDIA_ROOT, os.path.dirname(organisation.image.path) + '/new.png') os.rename(organisation.image.path, new_image_path) organisation.image = new_image_path organisation.logo = None organisation.save() assert os.path.isfile(new_image_path) assert not os.path.isfile(thumbnail_image_path) assert not os.path.isfile(thumbnail_logo_path) assert not os.path.isfile(image_path) assert not os.path.isfile(logo_path)
def test_delete_idea(topic_factory, comment_factory, rating_factory, ImagePNG): idea = topic_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, idea.image.path) thumbnail_path = createThumbnail(idea.image) for i in range(5): comment_factory(content_object=idea) comment_count = comments_models.Comment.objects.all().count() assert comment_count == len(idea.comments.all()) rating_factory(content_object=idea) rating_count = rating_models.Rating.objects.all().count() assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) count = idea_models.Topic.objects.all().count() assert count == 1 assert comment_count == 5 assert rating_count == 1 idea.delete() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path) count = idea_models.Topic.objects.all().count() comment_count = comments_models.Comment.objects.all().count() rating_count = rating_models.Rating.objects.all().count() assert count == 0 assert comment_count == 0
def test_delete_idea(idea_factory, comment_factory, rating_factory, ImagePNG): idea = idea_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, idea.image.path) thumbnail_path = helpers.createThumbnail(idea.image) for i in range(5): comment_factory(content_object=idea) comment_count = comments_models.Comment.objects.all().count() assert comment_count == len(idea.comments.all()) rating_factory(content_object=idea) rating_count = rating_models.Rating.objects.all().count() assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) count = idea_models.Idea.objects.all().count() assert count == 1 assert comment_count == 5 assert rating_count == 1 idea.delete() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path) count = idea_models.Idea.objects.all().count() comment_count = comments_models.Comment.objects.all().count() rating_count = rating_models.Rating.objects.all().count() assert count == 0 assert comment_count == 0 assert rating_count == 0
def test_delete_organisation(organisation_factory, ImagePNG): organisation = organisation_factory(image=ImagePNG, logo=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, organisation.image.path) logo_path = os.path.join(settings.MEDIA_ROOT, organisation.logo.path) thumbnail_image_path = helpers.createThumbnail(organisation.image) thumbnail_logo_path = helpers.createThumbnail(organisation.logo) assert os.path.isfile(thumbnail_image_path) assert os.path.isfile(thumbnail_logo_path) assert os.path.isfile(image_path) assert os.path.isfile(logo_path) count = models.Organisation.objects.all().count() assert count == 1 organisation.delete() assert not os.path.isfile(thumbnail_image_path) assert not os.path.isfile(thumbnail_logo_path) assert not os.path.isfile(image_path) assert not os.path.isfile(logo_path) count = models.Organisation.objects.all().count() assert count == 0
def test_image_deleted_after_update(user_factory, ImagePNG): user = user_factory(_avatar=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, user._avatar.path) thumbnail_path = helpers.createThumbnail(user._avatar) assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) user._avatar = None user.save() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path)
def test_image_deleted_after_update(topic_factory, ImagePNG): idea = topic_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, idea.image.path) thumbnail_path = createThumbnail(idea.image) assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) idea.image = None idea.save() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path)
def test_image_deleted_after_update(organisation_factory, ImagePNG): organisation = organisation_factory(image=ImagePNG, logo=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, organisation.image.path) logo_path = os.path.join(settings.MEDIA_ROOT, organisation.logo.path) thumbnail_image_path = helpers.createThumbnail(organisation.image) thumbnail_logo_path = helpers.createThumbnail(organisation.logo) assert os.path.isfile(thumbnail_image_path) assert os.path.isfile(thumbnail_logo_path) assert os.path.isfile(image_path) assert os.path.isfile(logo_path) organisation.image = ImagePNG.generate(None, None, True, {}) organisation.logo = None organisation.save() new_image_path = os.path.join(settings.MEDIA_ROOT, organisation.image.path) assert os.path.isfile(new_image_path) assert not os.path.isfile(thumbnail_image_path) assert not os.path.isfile(thumbnail_logo_path) assert not os.path.isfile(image_path) assert not os.path.isfile(logo_path)
def test_image_deleted_after_update(map_idea_factory, ImagePNG): mapidea = map_idea_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, mapidea.image.path) thumbnail_path = createThumbnail(mapidea.image) assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) mapidea.image = None mapidea.save() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path)
def test_image_deleted_after_update(idea_factory, ImagePNG): idea = idea_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, idea.image.path) thumbnail_path = helpers.createThumbnail(idea.image) assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) idea.image = None idea.save() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path)
def test_image_deleted_after_update(project_factory, ImagePNG): project = project_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, project.image.path) thumbnail_path = helpers.createThumbnail(project.image) assert os.path.isfile(image_path) assert os.path.isfile(thumbnail_path) project.image = None project.save() assert not os.path.isfile(image_path) assert not os.path.isfile(thumbnail_path)
def test_delete_project(project_factory, ImagePNG): project = project_factory(image=ImagePNG) image_path = os.path.join(settings.MEDIA_ROOT, project.image.path) thumbnail_path = helpers.createThumbnail(project.image) assert os.path.isfile(thumbnail_path) assert os.path.isfile(image_path) count = models.Project.objects.all().count() assert count == 1 project.delete() assert not os.path.isfile(thumbnail_path) assert not os.path.isfile(image_path) count = models.Project.objects.all().count() assert count == 0