Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: tests/test_fs_source.py

Issue 29968569: Issue 4014 - Publish python-abp on PyPI (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Add MANIFEST.in Created Dec. 29, 2018, 2:01 a.m.
Right Patch Set: Address comment on PS5 Created Jan. 3, 2019, 9:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « setup.py ('k') | tests/test_web_source.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 import pytest 16 import pytest
17 17
18 from abp.filters.sources import FSSource, NotFound, WebSource 18 from abp.filters.sources import FSSource, NotFound
19 19
20 20
21 @pytest.fixture 21 @pytest.fixture
22 def fssource_dir(tmpdir): 22 def fssource_dir(tmpdir):
23 tmpdir.mkdir('root') 23 tmpdir.mkdir('root')
24 not_in_source = tmpdir.join('not-in-source.txt') 24 not_in_source = tmpdir.join('not-in-source.txt')
25 not_in_source.write('! secret') 25 not_in_source.write('! secret')
26 root = tmpdir.join('root') 26 root = tmpdir.join('root')
27 root.mkdir('foo') 27 root.mkdir('foo')
28 foobar = root.join('foo', 'bar.txt') 28 foobar = root.join('foo', 'bar.txt')
29 foobar.write('! foo/bar.txt\n! end') 29 foobar.write('! foo/bar.txt\n! end')
30 return str(root) 30 return str(root)
31 31
32 32
33 @pytest.fixture 33 @pytest.fixture
34 def fssource(fssource_dir): 34 def fssource(fssource_dir):
35 return FSSource(fssource_dir) 35 return FSSource(fssource_dir)
36 36
37 37
38 @pytest.fixture
39 def websource(fssource_dir):
40 return WebSource(fssource_dir)
41
42
43 def test_read_file(fssource): 38 def test_read_file(fssource):
44 assert list(fssource.get('foo/bar.txt')) == ['! foo/bar.txt', '! end'] 39 assert list(fssource.get('foo/bar.txt')) == ['! foo/bar.txt', '! end']
45 40
46 41
47 def test_escape_source(fssource): 42 def test_escape_source(fssource):
48 with pytest.raises(ValueError): 43 with pytest.raises(ValueError):
49 list(fssource.get('../not-in-source.txt')) 44 list(fssource.get('../not-in-source.txt'))
50 45
51 46
52 def test_read_missing_file(fssource): 47 def test_read_missing_file(fssource):
53 with pytest.raises(NotFound): 48 with pytest.raises(NotFound):
54 list(fssource.get('foo/baz.txt')) 49 list(fssource.get('foo/baz.txt'))
55 50
56 51
57 def test_fssource_get_err(fssource): 52 def test_fssource_get_err(fssource):
58 with pytest.raises(IOError): 53 with pytest.raises(IOError):
59 list(fssource.get('')) 54 list(fssource.get(''))
60
61
62 def test_websource_get_err(websource):
Sebastian Noack 2018/12/29 03:24:56 Shouldn't this rather go in test_web_source.py?
rhowell 2019/01/03 04:42:27 Yeah, looks like it should, but this test is no lo
63 with pytest.raises(ValueError):
64 list(websource.get(''))
LEFTRIGHT

Powered by Google App Engine
This is Rietveld