forked from Flexget/Flexget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_archives.py
49 lines (42 loc) · 1.45 KB
/
test_archives.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
try:
import rarfile
except ImportError:
rarfile = None
class TestArchiveFilter:
config = """
tasks:
test_archives:
filesystem:
path: archives/
archives: yes
test_no_location:
mock:
- {title: 'no_location'}
archives: yes
"""
@pytest.mark.skipif(rarfile is None, reason='rarfile module required')
def test_rar(self, execute_task):
"""Test RAR acceptance"""
task = execute_task('test_archives')
assert task.find_entry(
'accepted', title='test_rar'
), 'test_rar.rar should have been accepted'
def test_zip(self, execute_task):
"""Test Zip acceptance"""
task = execute_task('test_archives')
assert task.find_entry(
'accepted', title='test_zip'
), 'test_zip.zip should have been accepted'
def test_invalid(self, execute_task):
"""Test non-archive rejection"""
task = execute_task('test_archives')
assert task.find_entry(
'rejected', title='invalid'
), 'invalid.zip should have been rejected'
def test_no_location(self, execute_task):
"""Test rejection of entries with no location"""
task = execute_task('test_no_location')
assert task.find_entry(
'rejected', title='no_location'
), 'no_location should have been rejected'