def test_get_all_media(self): expect(get_all_media())\ .to_be_instance_of(list).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)
def test_get_all_media(self): expect(get_all_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)
def test_get_all_media_with_additional(self): self._media_create(u'file.txt') expect(get_all_media())\ .to_be_instance_of(list).to_length(6)\ .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)\ .to_include(self._media_abs_path(u'file.txt'))
def test_get_all_media_with_additional(self): self._media_create(u'file.txt') expect(get_all_media())\ .to_be_instance_of(set).to_length(6)\ .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)\ .to_include(self._media_abs_path(u'file.txt'))
def test_get_all_media_with_exclude_folder(self): self._media_create(u'exclude_dir/file1.txt') self._media_create(u'exclude_dir/file2.txt') self._media_create(u'file3.txt') expect(get_all_media(['exclude_dir/*']))\ .to_be_instance_of(list).to_length(6)\ .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)\ .to_include(self._media_abs_path(u'file3.txt'))\ .Not.to_include(self._media_abs_path(u'exclude_dir/file1.txt'))\ .Not.to_include(self._media_abs_path(u'exclude_dir/file2.txt'))
def test_get_all_media_with_exclude_folder(self): self._media_create(u'exclude_dir/file1.txt') self._media_create(u'exclude_dir/file2.txt') self._media_create(u'file3.txt') expect(get_all_media(['exclude_dir/*']))\ .to_be_instance_of(set).to_length(6)\ .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)\ .to_include(self._media_abs_path(u'file3.txt'))\ .Not.to_include(self._media_abs_path(u'exclude_dir/file1.txt'))\ .Not.to_include(self._media_abs_path(u'exclude_dir/file2.txt'))
def test_get_all_media_with_exclude(self): self._media_create(u'file.txt') self._media_create(u'.file2.txt') self._media_create(u'test.txt') self._media_create(u'do_not_exclude/test.txt') self._media_create(u'one.png') self._media_create(u'two.png') self._media_create(u'three.png') expect(get_all_media(['.*', '*.png', 'test.txt']))\ .to_be_instance_of(list).to_length(7)\ .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)\ .to_include(self._media_abs_path(u'file.txt'))\ .Not.to_include(self._media_abs_path(u'.file2.txt'))\ .Not.to_include(self._media_abs_path(u'test.txt'))\ .to_include(self._media_abs_path(u'do_not_exclude/test.txt'))
def test_get_all_media_with_exclude(self): self._media_create(u'file.txt') self._media_create(u'.file2.txt') self._media_create(u'test.txt') self._media_create(u'do_not_exclude/test.txt') self._media_create(u'one.png') self._media_create(u'two.png') self._media_create(u'three.png') expect(get_all_media(['.*', '*.png', 'test.txt']))\ .to_be_instance_of(set).to_length(7)\ .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)\ .to_include(self._media_abs_path(u'file.txt'))\ .Not.to_include(self._media_abs_path(u'.file2.txt'))\ .Not.to_include(self._media_abs_path(u'test.txt'))\ .to_include(self._media_abs_path(u'do_not_exclude/test.txt'))
def test_get_all_media_win(self, mock_walk, mock_abspath): expect(get_all_media())\ .to_be_instance_of(list).to_length(1)\ .to_include(r'C:\dir\test\file.txt')
def test_get_all_media_win(self, mock_walk, mock_abspath): expect(get_all_media())\ .to_be_instance_of(set).to_length(1)\ .to_include(r'C:\dir\test\file.txt')
def test_get_all_media_with_minimum_file_age_2(self): self._media_create(u'fresh_file.txt', file_age=70) expect(get_all_media(minimum_file_age=60)) \ .to_be_instance_of(set).to_length(1) \ .to_include(self._media_abs_path(u'fresh_file.txt'))
def test_get_all_media_with_minimum_file_age(self): self._media_create(u'fresh_file.txt') expect(get_all_media(minimum_file_age=60)) \ .to_be_instance_of(set).to_length(0)