Пример #1
0
 def test_get_all_media(self):
     expect(_get_all_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)
 def test_get_all_media(self):
     expect(_get_all_media())\
         .to_be_instance_of(list).to_length(5)\
         .to_include(self.model1.file_field.name)\
         .to_include(self.model1.image_field.name)\
         .to_include(self.model2.file_field.name)\
         .to_include(self.model2.image_field.name)\
         .to_include(self.model3.custom_field.name)
Пример #3
0
 def test_get_all_media_with_folder(self):
     a_file = 'a/file.txt'
     b_file = 'b/file.txt'
     create_file_and_write(a_file)
     create_file_and_write(b_file)
     expect(_get_all_media(folders=['a']))\
         .to_be_instance_of(list).to_length(1)\
         .to_include(a_file)\
         .Not.to_include(b_file)
Пример #4
0
 def test_get_all_media_with_additional(self):
     create_file_and_write(u'file.txt')
     expect(_get_all_media())\
         .to_be_instance_of(list).to_length(6)\
         .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)\
         .to_include(u'file.txt')
 def test_get_all_media_with_additional(self):
     create_file_and_write('file.txt')
     expect(_get_all_media())\
         .to_be_instance_of(list).to_length(6)\
         .to_include(self.model1.file_field.name)\
         .to_include(self.model1.image_field.name)\
         .to_include(self.model2.file_field.name)\
         .to_include(self.model2.image_field.name)\
         .to_include(self.model3.custom_field.name)\
         .to_include('file.txt')
Пример #6
0
 def test_get_all_media_with_exclude_folder(self):
     create_file_and_write(u'exclude_dir/file1.txt')
     create_file_and_write(u'exclude_dir/file2.txt')
     create_file_and_write(u'file3.txt')
     expect(_get_all_media(['exclude_dir/*']))\
         .to_be_instance_of(list).to_length(6)\
         .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)\
         .to_include(u'file3.txt')\
         .Not.to_include(u'exclude_dir/file1.txt')\
         .Not.to_include(u'exclude_dir/file2.txt')
 def test_get_all_media_with_exclude(self):
     create_file_and_write('file.txt')
     create_file_and_write('.file2.txt')
     create_file_and_write('test.txt')
     create_file_and_write('one.png')
     create_file_and_write('two.png')
     create_file_and_write('three.png')
     expect(_get_all_media(['.*', '*.png', 'test.txt']))\
         .to_be_instance_of(list).to_length(6)\
         .to_include(self.model1.file_field.name)\
         .to_include(self.model1.image_field.name)\
         .to_include(self.model2.file_field.name)\
         .to_include(self.model2.image_field.name)\
         .to_include(self.model3.custom_field.name)\
         .to_include('file.txt')\
         .Not.to_include('.file2.txt')\
         .Not.to_include('test.txt')
 def test_get_all_media_with_exclude(self):
     create_file_and_write('file.txt')
     create_file_and_write('.file2.txt')
     create_file_and_write('test.txt')
     create_file_and_write('one.png')
     create_file_and_write('two.png')
     create_file_and_write('three.png')
     expect(_get_all_media(['.*', '*.png', 'test.txt']))\
         .to_be_instance_of(list).to_length(6)\
         .to_include(self.model1.file_field.name)\
         .to_include(self.model1.image_field.name)\
         .to_include(self.model2.file_field.name)\
         .to_include(self.model2.image_field.name)\
         .to_include(self.model3.custom_field.name)\
         .to_include('file.txt')\
         .Not.to_include('.file2.txt')\
         .Not.to_include('test.txt')
Пример #9
0
 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'))