hi i'm trying test mock django-filer save()
trigger post_save
signal.
models.py
import filer.fields.file import filerfilefield class deliveryinvoice(timestampedmodel): invoice_excel = filerfilefield(null=true, blank=true)
tests.py
from filer.models.filemodels import file filerfile django.core.files import file def test_if_delivery_invoice_number_updated_on_file_save_through_admin(self): patch("orders.utils.apply_invoice_number_to_orders") signal_mock_handler: post_save.connect(signal_mock_handler, sender=deliveryinvoice) filename = 'test_invoice_excel' filepath = 'orders/fixtures/delivery_invoices.xlsx' open(filepath, 'rb') f: file_obj = file(f, name=filename) error -> invoice_excel = filerfile.objects.create(owner=self.user, file=file_obj, original_filename=filename) instance = deliveryinvoice(invoice_excel=invoice_excel) instance.save() self.asserttrue(signal_mock_handler.called)
error message
.... file "/users/mhjeon/.pyenv/versions/3.6.0/envs/modernlab/lib/python3.6/site-packages/boto/auth.py", line 1070, in _wrapper if test in self.host: typeerror: argument of type 'nonetype' not iterable
the code used work few days ago, after code refactoring believe not related orders models, fail calle django-filer's filermodel.save() method. wrong?/
Comments
Post a Comment