def test_create_add_more(any_added_issue, any_indexer): c1 = Changeset.objects.create(indexer=any_indexer, state=states.OPEN, change_type=CTYPES['issue_add']) any_added_issue = Issue.objects.get(pk=any_added_issue.pk) # With after=None, should insert the issue at the beginning. rev1 = IssueRevision(changeset=c1, series=any_added_issue.series) rev1.save() rev1.commit_to_display() # It's necessary to re-fetch (not just refresh) the various issues # to get the calculated sort codes loaded. original_issue = Issue.objects.get(pk=any_added_issue.pk) issue1 = Issue.objects.get(pk=rev1.issue.pk) assert issue1.sort_code < original_issue.sort_code c2 = Changeset.objects.create(indexer=any_indexer, state=states.OPEN, change_type=CTYPES['issue_add']) rev2 = IssueRevision(changeset=c2, series=any_added_issue.series, after=rev1.issue) rev2.save() rev2.commit_to_display() # Again, re-fetch all the things. original_issue = Issue.objects.get(pk=any_added_issue.pk) issue1 = Issue.objects.get(pk=rev1.issue.pk) issue2 = Issue.objects.get(pk=rev2.issue.pk) assert issue2.sort_code < original_issue.sort_code assert issue1.sort_code < issue2.sort_code
def test_create_add_more(any_added_issue, any_indexer): c1 = Changeset.objects.create(indexer=any_indexer, state=states.OPEN, change_type=CTYPES['issue_add']) any_added_issue = Issue.objects.get(pk=any_added_issue.pk) # With after=None, should insert the issue at the beginning. rev1 = IssueRevision(changeset=c1, series=any_added_issue.series) rev1.save() rev1.commit_to_display() # It's necessary to re-fetch (not just refresh) the various issues # to get the calculated sort codes loaded. original_issue = Issue.objects.get(pk=any_added_issue.pk) issue1 = Issue.objects.get(pk=rev1.issue.pk) assert issue1.sort_code < original_issue.sort_code c2 = Changeset.objects.create(indexer=any_indexer, state=states.OPEN, change_type=CTYPES['issue_add']) rev2 = IssueRevision(changeset=c2, series=any_added_issue.series, after=rev1.issue) rev2.save() rev2.commit_to_display() # Again, re-fetch all the things. original_issue = Issue.objects.get(pk=any_added_issue.pk) issue1 = Issue.objects.get(pk=rev1.issue.pk) issue2 = Issue.objects.get(pk=rev2.issue.pk) assert issue2.sort_code < original_issue.sort_code assert issue1.sort_code < issue2.sort_code
def any_added_issue_rev(any_adding_changeset, issue_add_values): indicia_printer = issue_add_values.pop('indicia_printer') rev = IssueRevision(changeset=any_adding_changeset, **issue_add_values) rev.save() rev.indicia_printer.set([ indicia_printer, ]) return rev
def convert(self, changeset): if self.volume is None: volume = '' else: volume = '%s' % self.volume display_series = Series.objects.get(id=self.series_id) if display_series.year_ended and display_series.year_ended < 1970: no_isbn = True else: no_isbn = False if display_series.year_ended and display_series.year_ended < 1974: no_barcode = True else: no_barcode = False issue = Issue.objects.get(id=self.id) if not self.publication_date: self.publication_date = '' if not self.key_date: self.key_date = '' if not self.price: self.price = '' revision = IssueRevision(changeset=changeset, issue=issue, number=self.number, volume=volume, series=display_series, publication_date=self.publication_date, key_date=self.key_date.replace('.', '-'), price=self.price, no_barcode=no_barcode, no_isbn=no_isbn, date_inferred=changeset.date_inferred) revision.save() return revision
def test_noncomics_counts(any_added_series_rev, issue_add_values, any_adding_changeset, any_variant_adding_changeset, any_deleting_changeset): # This is written out in long form because while it could be broken # up into fixtures and separate cases, it is only this one specific # sequence of operations that needs any of this code right now. s_rev = any_added_series_rev s_rev.is_comics_publication = False s_rev.save() with mock.patch(UPDATE_ALL) as updater: s_rev.commit_to_display() updater.has_calls([ mock.call({}, language=None, country=None, negate=True), mock.call({'series': 1}, language=s_rev.series.language, country=s_rev.series.country), ]) assert updater.call_count == 2 series = Series.objects.get(pk=s_rev.series.pk) issue_add_values['series'] = series i_rev = IssueRevision(changeset=any_adding_changeset, **issue_add_values) i_rev.save() i_rev = IssueRevision.objects.get(pk=i_rev.pk) old_series_issue_count = i_rev.series.issue_count old_ind_pub_issue_count = i_rev.indicia_publisher.issue_count old_brand_issue_count = i_rev.brand.issue_count old_brand_group_counts = { group.pk: group.issue_count for group in i_rev.brand.group.all() } old_publisher_issue_count = i_rev.series.publisher.issue_count with mock.patch(UPDATE_ALL) as updater: i_rev.commit_to_display() # Changeset must be approved so we can re-edit this later. i_rev.changeset.state = states.APPROVED i_rev.changeset.save() updater.has_calls([ mock.call({}, language=None, country=None, negate=True), mock.call({ 'stories': 0, 'covers': 0 }, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 i_rev = IssueRevision.objects.get(pk=i_rev.pk) s = i_rev.issue.series # Non-comics issues do not affect the issue counts EXCEPT on the series. assert s.issue_count == old_series_issue_count + 1 assert s.publisher.issue_count == old_publisher_issue_count assert i_rev.issue.brand.issue_count == old_brand_issue_count assert { group.pk: group.issue_count for group in i_rev.issue.brand.group.all() } == old_brand_group_counts assert i_rev.issue.indicia_publisher.issue_count == old_ind_pub_issue_count # Now do it all again with a variant added to the new issue. v_rev = IssueRevision(changeset=any_variant_adding_changeset, number='100', variant_of=i_rev.issue, variant_name='alternate cover', series=i_rev.series, brand=i_rev.brand, indicia_publisher=i_rev.indicia_publisher) v_rev.save() v_rev = IssueRevision.objects.get(pk=v_rev.pk) old_series_issue_count = v_rev.series.issue_count old_ind_pub_issue_count = v_rev.indicia_publisher.issue_count old_brand_issue_count = v_rev.brand.issue_count old_brand_group_counts = { group.pk: group.issue_count for group in v_rev.brand.group.all() } old_publisher_issue_count = v_rev.series.publisher.issue_count with mock.patch(UPDATE_ALL) as updater: v_rev.commit_to_display() # Changeset must be approved so we can re-edit this later. v_rev.changeset.state = states.APPROVED v_rev.changeset.save() updater.has_calls([ mock.call({ 'stories': 0, 'covers': 0 }, language=None, country=None, negate=True), mock.call({ 'stories': 0, 'covers': 0 }, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 v_rev = IssueRevision.objects.get(pk=v_rev.pk) s = v_rev.issue.series # Non-comics variants do not affect the issue counts on anything. assert s.issue_count == old_series_issue_count assert s.publisher.issue_count == old_publisher_issue_count assert v_rev.issue.brand.issue_count == old_brand_issue_count assert { group.pk: group.issue_count for group in v_rev.issue.brand.group.all() } == old_brand_group_counts assert v_rev.issue.indicia_publisher.issue_count == old_ind_pub_issue_count # Now delete the variant, should still have the same counts. del_v_rev = IssueRevision.clone( changeset=any_deleting_changeset, data_object=Issue.objects.get(pk=v_rev.issue.pk)) del_v_rev.deleted = True del_v_rev.save() del_v_rev = IssueRevision.objects.get(pk=del_v_rev.pk) with mock.patch(UPDATE_ALL) as updater: del_v_rev.commit_to_display() del_v_rev = IssueRevision.objects.get(pk=del_v_rev.pk) updater.has_calls([ mock.call({ 'stories': 0, 'covers': 0 }, language=None, country=None, negate=True), mock.call({ 'stories': 0, 'covers': 0 }, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 s = Series.objects.get(pk=del_v_rev.series.pk) i = Issue.objects.get(pk=del_v_rev.issue.pk) assert s.issue_count == old_series_issue_count assert s.publisher.issue_count == old_publisher_issue_count assert i.brand.issue_count == old_brand_issue_count assert {group.pk: group.issue_count for group in i.brand.group.all()} == old_brand_group_counts assert i.indicia_publisher.issue_count == old_ind_pub_issue_count # Finally, delete the base issue, check for only series.issue_count deleting_variant_changeset = Changeset( state=states.OPEN, change_type=0, indexer=any_deleting_changeset.indexer) deleting_variant_changeset.save() del_i_rev = IssueRevision.clone( changeset=deleting_variant_changeset, data_object=Issue.objects.get(pk=i_rev.issue.pk)) del_i_rev.deleted = True del_i_rev.save() del_i_rev = IssueRevision.objects.get(pk=del_i_rev.pk) with mock.patch(UPDATE_ALL) as updater: del_i_rev.commit_to_display() del_i_rev = IssueRevision.objects.get(pk=del_v_rev.pk) updater.has_calls([ mock.call({ 'stories': 0, 'covers': 0 }, language=None, country=None, negate=True), mock.call({ 'stories': 0, 'covers': 0 }, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 s = Series.objects.get(pk=del_i_rev.series.pk) i = Issue.objects.get(pk=del_i_rev.issue.pk) # Series issue counts are adjusted even for non comics. assert s.issue_count == old_series_issue_count - 1 assert s.publisher.issue_count == old_publisher_issue_count assert i.brand.issue_count == old_brand_issue_count assert {group.pk: group.issue_count for group in i.brand.group.all()} == old_brand_group_counts assert i.indicia_publisher.issue_count == old_ind_pub_issue_count
def handle_uploaded_cover(request, cover, issue, variant=False, revision_lock=None): ''' process the uploaded file and generate CoverRevision ''' try: if variant: form = UploadVariantScanForm(request.POST, request.FILES) else: form = UploadScanForm(request.POST, request.FILES) except IOError: # sometimes uploads misbehave. connection dropped ? error_text = 'Something went wrong with the upload. ' + \ 'Please <a href="' + request.path + '">try again</a>.' return render_error(request, error_text, redirect=False, is_safe=True) if not form.is_valid(): return _display_cover_upload_form(request, form, cover, issue, variant=variant) # process form if form.cleaned_data['is_gatefold']: return handle_gatefold_cover(request, cover, issue, form) scan = form.cleaned_data['scan'] file_source = form.cleaned_data['source'] marked = form.cleaned_data['marked'] # create OI records changeset = Changeset(indexer=request.user, state=states.OPEN, change_type=CTYPES['cover']) changeset.save() if cover: # upload_type is 'replacement': revision = CoverRevision(changeset=changeset, issue=issue, cover=cover, file_source=file_source, marked=marked, is_replacement=True) revision_lock.changeset = changeset revision_lock.save() revision.previous_revision = cover.revisions.get( next_revision=None, changeset__state=states.APPROVED, committed=True) else: revision = CoverRevision(changeset=changeset, issue=issue, file_source=file_source, marked=marked) revision.save() # if uploading a variant, generate an issue_revision for # the variant issue and copy the values which would not change # TODO are these reasonable assumptions below ? if variant: current_variants = issue.variant_set.all().order_by('-sort_code') if current_variants: add_after = current_variants[0] else: add_after = issue issue_revision = IssueRevision( changeset=changeset, after=add_after, number=issue.number, title=issue.title, no_title=issue.no_title, volume=issue.volume, no_volume=issue.no_volume, display_volume_with_number=issue.display_volume_with_number, variant_of=issue, variant_name=form.cleaned_data['variant_name'], page_count=issue.page_count, page_count_uncertain=issue.page_count_uncertain, series=issue.series, editing=issue.editing, no_editing=issue.no_editing, reservation_requested=form.cleaned_data['reservation_requested']) issue_revision.save() if form.cleaned_data['variant_artwork']: story_revision = StoryRevision( changeset=changeset, type=StoryType.objects.get(name='cover'), no_script=True, pencils='?', inks='?', colors='?', no_letters=True, no_editing=True, sequence_number=0, page_count=2 if form.cleaned_data['is_wraparound'] else 1, ) story_revision.save() # put new uploaded covers into # media/<LOCAL_NEW_SCANS>/<monthname>_<year>/ # with name # <revision_id>_<date>_<time>.<ext> scan_name = str(revision.id) + os.path.splitext(scan.name)[1] upload_dir = settings.MEDIA_ROOT + LOCAL_NEW_SCANS + \ changeset.created.strftime('%B_%Y').lower() destination_name = os.path.join(upload_dir, scan_name) try: # essentially only needed at beginning of the month check_cover_dir(upload_dir) except IOError: changeset.delete() error_text = "Problem with file storage for uploaded " + \ "cover, please report an error." return render_error(request, error_text, redirect=False) # write uploaded file destination = open(destination_name, 'wb') for chunk in scan.chunks(): destination.write(chunk) destination.close() try: # generate different sizes we are using im = pyImage.open(destination.name) large_enough = False if form.cleaned_data['is_wraparound']: # wraparounds need to have twice the width if im.size[0] >= 800 and im.size[1] >= 400: large_enough = True elif min(im.size) >= 400: large_enough = True if large_enough: if form.cleaned_data['is_wraparound']: revision.is_wraparound = True revision.front_left = im.size[0] / 2 revision.front_right = im.size[0] revision.front_bottom = im.size[1] revision.front_top = 0 revision.save() generate_sizes(revision, im) else: changeset.delete() os.remove(destination.name) info_text = "Image is too small, only " + str(im.size) + \ " in size." return _display_cover_upload_form(request, form, cover, issue, info_text=info_text, variant=variant) except IOError as e: # just in case, django *should* have taken care of file type changeset.delete() os.remove(destination.name) info_text = 'Error: File \"' + scan.name + \ '" is not a valid picture.' return _display_cover_upload_form(request, form, cover, issue, info_text=info_text, variant=variant) # all done, we can save the state return finish_cover_revision(request, revision, form.cleaned_data)
def handle_uploaded_cover(request, cover, issue, variant=False, revision_lock=None): ''' process the uploaded file and generate CoverRevision ''' try: if variant: form = UploadVariantScanForm(request.POST, request.FILES) else: form = UploadScanForm(request.POST, request.FILES) except IOError: # sometimes uploads misbehave. connection dropped ? error_text = 'Something went wrong with the upload. ' + \ 'Please <a href="' + request.path + '">try again</a>.' return render_error(request, error_text, redirect=False, is_safe=True) if not form.is_valid(): return _display_cover_upload_form(request, form, cover, issue, variant=variant) # process form if form.cleaned_data['is_gatefold']: return handle_gatefold_cover(request, cover, issue, form) scan = form.cleaned_data['scan'] file_source = form.cleaned_data['source'] marked = form.cleaned_data['marked'] # create OI records changeset = Changeset(indexer=request.user, state=states.OPEN, change_type=CTYPES['cover']) changeset.save() if cover: # upload_type is 'replacement': revision = CoverRevision(changeset=changeset, issue=issue, cover=cover, file_source=file_source, marked=marked, is_replacement = True) revision_lock.changeset = changeset revision_lock.save() revision.previous_revision = cover.revisions.get( next_revision=None, changeset__state=states.APPROVED, committed=True) else: revision = CoverRevision(changeset=changeset, issue=issue, file_source=file_source, marked=marked) revision.save() # if uploading a variant, generate an issue_revision for # the variant issue and copy the values which would not change # TODO are these reasonable assumptions below ? if variant: current_variants = issue.variant_set.all().order_by('-sort_code') if current_variants: add_after = current_variants[0] else: add_after = issue issue_revision = IssueRevision(changeset=changeset, after=add_after, number=issue.number, title=issue.title, no_title=issue.no_title, volume=issue.volume, no_volume=issue.no_volume, display_volume_with_number=issue.display_volume_with_number, variant_of=issue, variant_name=form.cleaned_data['variant_name'], page_count=issue.page_count, page_count_uncertain=issue.page_count_uncertain, series=issue.series, editing=issue.editing, no_editing=issue.no_editing, reservation_requested=form.cleaned_data['reservation_requested'] ) issue_revision.save() if form.cleaned_data['variant_artwork']: story_revision = StoryRevision(changeset=changeset, type=StoryType.objects.get(name='cover'), no_script=True, pencils='?', inks='?', colors='?', no_letters=True, no_editing=True, sequence_number=0, page_count=2 if form.cleaned_data['is_wraparound'] else 1, ) story_revision.save() # put new uploaded covers into # media/<LOCAL_NEW_SCANS>/<monthname>_<year>/ # with name # <revision_id>_<date>_<time>.<ext> scan_name = str(revision.id) + os.path.splitext(scan.name)[1] upload_dir = settings.MEDIA_ROOT + LOCAL_NEW_SCANS + \ changeset.created.strftime('%B_%Y').lower() destination_name = os.path.join(upload_dir, scan_name) try: # essentially only needed at beginning of the month check_cover_dir(upload_dir) except IOError: changeset.delete() error_text = "Problem with file storage for uploaded " + \ "cover, please report an error." return render_error(request, error_text, redirect=False) # write uploaded file destination = open(destination_name, 'wb') for chunk in scan.chunks(): destination.write(chunk) destination.close() try: # generate different sizes we are using im = pyImage.open(destination.name) large_enough = False if form.cleaned_data['is_wraparound']: # wraparounds need to have twice the width if im.size[0] >= 800 and im.size[1] >= 400: large_enough = True elif min(im.size) >= 400: large_enough = True if large_enough: if form.cleaned_data['is_wraparound']: revision.is_wraparound = True revision.front_left = im.size[0]/2 revision.front_right = im.size[0] revision.front_bottom = im.size[1] revision.front_top = 0 revision.save() generate_sizes(revision, im) else: changeset.delete() os.remove(destination.name) info_text = "Image is too small, only " + str(im.size) + \ " in size." return _display_cover_upload_form(request, form, cover, issue, info_text=info_text, variant=variant) except IOError as e: # just in case, django *should* have taken care of file type changeset.delete() os.remove(destination.name) info_text = 'Error: File \"' + scan.name + \ '" is not a valid picture.' return _display_cover_upload_form(request, form, cover, issue, info_text=info_text, variant=variant) # all done, we can save the state return finish_cover_revision(request, revision, form.cleaned_data)
def any_added_variant_rev(any_variant_adding_changeset, variant_add_values): rev = IssueRevision(changeset=any_variant_adding_changeset, **variant_add_values) rev.save() return IssueRevision.objects.get(pk=rev.pk)
def any_added_variant_rev(any_variant_adding_changeset, variant_add_values): rev = IssueRevision(changeset=any_variant_adding_changeset, **variant_add_values) rev.save() return IssueRevision.objects.get(pk=rev.pk)
def any_added_issue_rev(any_adding_changeset, issue_add_values): rev = IssueRevision(changeset=any_adding_changeset, **issue_add_values) rev.save() return rev
def any_added_issue_rev(any_adding_changeset, issue_add_values): rev = IssueRevision(changeset=any_adding_changeset, **issue_add_values) rev.save() return rev
def test_noncomics_counts(any_added_series_rev, issue_add_values, any_adding_changeset, any_variant_adding_changeset, any_deleting_changeset): # This is written out in long form because while it could be broken # up into fixtures and separate cases, it is only this one specific # sequence of operations that needs any of this code right now. s_rev = any_added_series_rev s_rev.is_comics_publication = False s_rev.save() with mock.patch(UPDATE_ALL) as updater: s_rev.commit_to_display() updater.has_calls([ mock.call({}, language=None, country=None, negate=True), mock.call({'series': 1}, language=s_rev.series.language, country=s_rev.series.country), ]) assert updater.call_count == 2 series = Series.objects.get(pk=s_rev.series.pk) issue_add_values['series'] = series i_rev = IssueRevision(changeset=any_adding_changeset, **issue_add_values) i_rev.save() i_rev = IssueRevision.objects.get(pk=i_rev.pk) old_series_issue_count = i_rev.series.issue_count old_ind_pub_issue_count = i_rev.indicia_publisher.issue_count old_brand_issue_count = i_rev.brand.issue_count old_brand_group_counts = {group.pk: group.issue_count for group in i_rev.brand.group.all()} old_publisher_issue_count = i_rev.series.publisher.issue_count with mock.patch(UPDATE_ALL) as updater: i_rev.commit_to_display() # Changeset must be approved so we can re-edit this later. i_rev.changeset.state = states.APPROVED i_rev.changeset.save() updater.has_calls([ mock.call({}, language=None, country=None, negate=True), mock.call({'stories': 0, 'covers': 0}, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 i_rev = IssueRevision.objects.get(pk=i_rev.pk) s = i_rev.issue.series # Non-comics issues do not affect the issue counts EXCEPT on the series. assert s.issue_count == old_series_issue_count + 1 assert s.publisher.issue_count == old_publisher_issue_count assert i_rev.issue.brand.issue_count == old_brand_issue_count assert { group.pk: group.issue_count for group in i_rev.issue.brand.group.all() } == old_brand_group_counts assert i_rev.issue.indicia_publisher.issue_count == old_ind_pub_issue_count # Now do it all again with a variant added to the new issue. v_rev = IssueRevision(changeset=any_variant_adding_changeset, number='100', variant_of=i_rev.issue, variant_name='alternate cover', series=i_rev.series, brand=i_rev.brand, indicia_publisher=i_rev.indicia_publisher) v_rev.save() v_rev = IssueRevision.objects.get(pk=v_rev.pk) old_series_issue_count = v_rev.series.issue_count old_ind_pub_issue_count = v_rev.indicia_publisher.issue_count old_brand_issue_count = v_rev.brand.issue_count old_brand_group_counts = {group.pk: group.issue_count for group in v_rev.brand.group.all()} old_publisher_issue_count = v_rev.series.publisher.issue_count with mock.patch(UPDATE_ALL) as updater: v_rev.commit_to_display() # Changeset must be approved so we can re-edit this later. v_rev.changeset.state = states.APPROVED v_rev.changeset.save() updater.has_calls([ mock.call({'stories': 0, 'covers': 0}, language=None, country=None, negate=True), mock.call({'stories': 0, 'covers': 0}, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 v_rev = IssueRevision.objects.get(pk=v_rev.pk) s = v_rev.issue.series # Non-comics variants do not affect the issue counts on anything. assert s.issue_count == old_series_issue_count assert s.publisher.issue_count == old_publisher_issue_count assert v_rev.issue.brand.issue_count == old_brand_issue_count assert { group.pk: group.issue_count for group in v_rev.issue.brand.group.all() } == old_brand_group_counts assert v_rev.issue.indicia_publisher.issue_count == old_ind_pub_issue_count # Now delete the variant, should still have the same counts. del_v_rev = IssueRevision.clone( changeset=any_deleting_changeset, data_object=Issue.objects.get(pk=v_rev.issue.pk)) del_v_rev.deleted = True del_v_rev.save() del_v_rev = IssueRevision.objects.get(pk=del_v_rev.pk) with mock.patch(UPDATE_ALL) as updater: del_v_rev.commit_to_display() del_v_rev = IssueRevision.objects.get(pk=del_v_rev.pk) updater.has_calls([ mock.call({'stories': 0, 'covers': 0}, language=None, country=None, negate=True), mock.call({'stories': 0, 'covers': 0}, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 s = Series.objects.get(pk=del_v_rev.series.pk) i = Issue.objects.get(pk=del_v_rev.issue.pk) assert s.issue_count == old_series_issue_count assert s.publisher.issue_count == old_publisher_issue_count assert i.brand.issue_count == old_brand_issue_count assert {group.pk: group.issue_count for group in i.brand.group.all()} == old_brand_group_counts assert i.indicia_publisher.issue_count == old_ind_pub_issue_count # Finally, delete the base issue, check for only series.issue_count deleting_variant_changeset = Changeset( state=states.OPEN, change_type=0, indexer=any_deleting_changeset.indexer) deleting_variant_changeset.save() del_i_rev = IssueRevision.clone( changeset=deleting_variant_changeset, data_object=Issue.objects.get(pk=i_rev.issue.pk)) del_i_rev.deleted = True del_i_rev.save() del_i_rev = IssueRevision.objects.get(pk=del_i_rev.pk) with mock.patch(UPDATE_ALL) as updater: del_i_rev.commit_to_display() del_i_rev = IssueRevision.objects.get(pk=del_v_rev.pk) updater.has_calls([ mock.call({'stories': 0, 'covers': 0}, language=None, country=None, negate=True), mock.call({'stories': 0, 'covers': 0}, language=i_rev.series.language, country=i_rev.series.country), ]) assert updater.call_count == 2 s = Series.objects.get(pk=del_i_rev.series.pk) i = Issue.objects.get(pk=del_i_rev.issue.pk) # Series issue counts are adjusted even for non comics. assert s.issue_count == old_series_issue_count - 1 assert s.publisher.issue_count == old_publisher_issue_count assert i.brand.issue_count == old_brand_issue_count assert {group.pk: group.issue_count for group in i.brand.group.all()} == old_brand_group_counts assert i.indicia_publisher.issue_count == old_ind_pub_issue_count