def test_post_api_delete(self, api): '''It should delete a post from the API''' post = PostFactory() with api.user(AdminFactory()): response = api.delete(url_for('api.post', post=post)) assert204(response) assert Post.objects.count() == 0
def test_reuse_api_delete(self, api): '''It should delete a reuse from the API''' user = api.login() reuse = ReuseFactory(owner=user) response = api.delete(url_for('api.reuse', reuse=reuse)) assert204(response) assert Reuse.objects.count() == 1 assert Reuse.objects[0].deleted is not None
def test_organization_api_delete(self, api): '''It should delete an organization from the API''' user = api.login() member = Member(user=user, role='admin') org = OrganizationFactory(members=[member]) response = api.delete(url_for('api.organization', org=org)) assert204(response) assert Organization.objects.count() is 1 assert Organization.objects[0].deleted is not None
def test_delete_source(self, api): user = api.login() source = HarvestSourceFactory(owner=user) url = url_for('api.harvest_source', ident=str(source.id)) response = api.delete(url) assert204(response) deleted_sources = HarvestSource.objects(deleted__exists=True) assert len(deleted_sources) == 1
def test_delete(self, api): badge = self.factory() self.reuse.add_badge(badge.kind) response = api.delete( url_for('api.reuse_badge', reuse=self.reuse, badge_kind=str(badge.kind))) assert204(response) self.reuse.reload() assert len(self.reuse.badges) == 0
def test_delete(self, api): badge = self.factory() self.organization.add_badge(badge.kind) self.organization.save() url = url_for('api.organization_badge', org=self.organization, badge_kind=str(badge.kind)) with assert_emit(on_badge_removed): response = api.delete(url) assert204(response) self.organization.reload() assert len(self.organization.badges) is 0
def test_delete_member(self, api): user = api.login() deleted_user = UserFactory() organization = OrganizationFactory(members=[ Member(user=user, role='admin'), Member(user=deleted_user, role='editor') ]) api_url = url_for('api.member', org=organization, user=deleted_user) response = api.delete(api_url) assert204(response) organization.reload() assert not organization.is_member(deleted_user)
def test_unschedule_source(self, api): '''It should allow to unschedule a source if admin''' api.login(AdminFactory()) periodic_task = PeriodicTask.objects.create( task='harvest', name=faker.name(), description=faker.sentence(), enabled=True, crontab=PeriodicTask.Crontab()) source = HarvestSourceFactory(periodic_task=periodic_task) url = url_for('api.schedule_harvest_source', ident=str(source.id)) response = api.delete(url) assert204(response) source.reload() assert source.periodic_task is None