コード例 #1
0
 def test_relative_path(self):
     FileFieldsModel.objects.create(
         file_field='./test_rel_path/file1.txt',
     )
     expect(get_used_media()) \
         .to_be_instance_of(list)\
         .to_include('test_rel_path/file1.txt')
コード例 #2
0
 def test_relative_path(self):
     FileFieldsModel.objects.create(
         file_field='./test_rel_path/file1.txt',
     )
     expect(get_used_media()) \
         .to_be_instance_of(set)\
         .to_include(self._media_abs_path('test_rel_path/file1.txt'))
コード例 #3
0
 def test_get_used_media(self):
     expect(get_used_media())\
         .to_be_instance_of(list).to_length(5)\
         .to_include(self.model1.file_field.url)\
         .to_include(self.model1.image_field.url)\
         .to_include(self.model2.file_field.url)\
         .to_include(self.model2.image_field.url)\
         .to_include(self.model3.custom_field.url)
コード例 #4
0
 def test_get_used_media(self):
     expect(get_used_media())\
         .to_be_instance_of(set).to_length(5)\
         .to_include(self.model1.file_field.path)\
         .to_include(self.model1.image_field.path)\
         .to_include(self.model2.file_field.path)\
         .to_include(self.model2.image_field.path)\
         .to_include(self.model3.custom_field.path)
コード例 #5
0
    def test_custom_manager(self):
        model_active = CustomManagerModel.objects.create(
            active=True,
            file_field=self._create_file('file_custom_1.txt'),
        )
        model_not_active = CustomManagerModel.objects.create(
            active=False,
            file_field=self._create_file('file_custom_2.txt'),
        )

        expect(get_used_media()) \
            .to_be_instance_of(set) \
            .to_include(model_active.file_field.path) \
            .to_include(model_not_active.file_field.path)