diff --git a/ecommerce/extensions/iap/management/commands/sync_mobile_seats_price_and_expiry_with_web.py b/ecommerce/extensions/iap/management/commands/sync_mobile_seats_price_and_expiry_with_web.py index 0e32c7ba09a..49e6f890f76 100644 --- a/ecommerce/extensions/iap/management/commands/sync_mobile_seats_price_and_expiry_with_web.py +++ b/ecommerce/extensions/iap/management/commands/sync_mobile_seats_price_and_expiry_with_web.py @@ -43,9 +43,12 @@ def handle(self, *args, **options): attribute_values__value_text=CertificateType.VERIFIED, ).exclude(stockrecords__partner_sku__icontains="mobile").first() + if not web_seat: + logger.info('While syncing could not find web seat for %s', product.title) + continue + for mobile_seat in mobile_seats: - info = 'Syncing {} with {}'.format(mobile_seat.title, web_seat.title) - logger.info(info) + logger.info('Syncing %s with %s', mobile_seat.title, web_seat.title) stock_record = mobile_seat.stockrecords.all()[0] stock_record.price_excl_tax = web_seat.stockrecords.all()[0].price_excl_tax diff --git a/ecommerce/extensions/iap/management/commands/tests/test_sync_mobile_seats_price_and_expiry_with_web.py b/ecommerce/extensions/iap/management/commands/tests/test_sync_mobile_seats_price_and_expiry_with_web.py index b04f0dfb481..640ab403c29 100644 --- a/ecommerce/extensions/iap/management/commands/tests/test_sync_mobile_seats_price_and_expiry_with_web.py +++ b/ecommerce/extensions/iap/management/commands/tests/test_sync_mobile_seats_price_and_expiry_with_web.py @@ -18,6 +18,10 @@ def setUp(self): self.course_with_audit_seat = self.create_course_and_seats(create_mobile_seats=False, create_web_seat=False) self.course_with_unsync_seats = self.create_course_and_seats(create_mobile_seats=True, create_web_seat=True) self.course_with_unsync_seats2 = self.create_course_and_seats(create_mobile_seats=True, create_web_seat=True) + self.course_with_mobile_seats = self.create_course_and_seats(create_mobile_seats=True, create_web_seat=True) + web_seat = self.get_web_seat_for_course(self.course_with_mobile_seats) + web_seat.delete() + mobile_seats = self.get_mobile_seats_for_course(self.course_with_unsync_seats) mobile_seats = list(mobile_seats) + list(self.get_mobile_seats_for_course(self.course_with_unsync_seats2))