django-filer: FilerFile model not being saved; NoneType error raised instead. Why?

203 views Asked by At

Hi I'm trying to test mock django-filer save() that 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 as FilerFile
from django.core.files import File

def test_if_delivery_invoice_number_updated_on_file_save_through_admin(self):
    with patch("orders.utils.apply_invoice_number_to_orders") as signal_mock_handler:
        post_save.connect(signal_mock_handler, sender=DeliveryInvoice)

        filename = 'test_invoice_excel'
        filepath = 'orders/fixtures/delivery_invoices.xlsx'

        with open(filepath, 'rb') as 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' is not iterable

The code used to work a few days ago, but after some code refactoring which I believe is not related to the orders models, it suddenly fail to calle the django-filer's FilerModel.save() method. What could be wrong?/

0

There are 0 answers