I am writing some unit-tests for an app. One of the features of this app is that it allows the user to upload videos to the server (or S3, depending on the configuration).
The difficulty I am having is coming up with a meaningful unit-test for this. So, the question is two-fold. First, what is a solid way to test this functionality?
Second, the following test fails because videofile
entry in the dictionary is a string. Having done prints, I can see that in a real upload it is actually of type <class django.db.models.fields.files.FieldFile>
. How should one go about creating this in a test to make the types similar to the real upload via the browser?
class VideoFormTest(TestCase):
def test_upload_form_valid(self):
form = VideoForm(data={'title':"Test Video Title", 'videofile':"videos/navigator.mp4"})
self.assertTrue(form.is_valid())