def setUpTestData(cls): cls.user = User.objects.create_user(username='******') cls.user.set_password('12345') cls.user.save() temp_file = tempfile.NamedTemporaryFile(delete=False) test_image = get_temporary_image(temp_file) temp_name = test_image.name test_image.close() os.rename(temp_name, os.path.join(tempfile.gettempdir(), 'test_file.jpg')) test_image = djFile(open(os.path.join(tempfile.gettempdir(), 'test_file.jpg'), 'rb')) cls.file = test_image
def setup(self): user_obj = User.objects.create_user(username = "******", password="******", email="*****@*****.**") user_obj.save() user_obj_2 = User.objects.create_user(username = "******", password="******", email="*****@*****.**") user_obj_2.save() audio_type = FileType.objects.create(id = 1, Name='Audio') audio_type.save() video_type = FileType.objects.create(id = 2, Name='Video') video_type.save() audio_path = os.getcwd() + '/Test/TestFiles/test_video_1.mp3' f = open(audio_path, 'rb') audiotest1 = djFile(f) file_obj_Audio = File.objects.create(Name='Audio File', Type = audio_type, User = user_obj) file_obj_Audio.Content = audiotest1 file_obj_Audio.save()