Passed
Push — main ( 6e4731...702ebc )
by Douglas
02:44
created

tests.pocketutils.misc.test_web_resource   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 0
1
import pytest
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
Unable to import 'pytest'
Loading history...
2
3
4
class TestWebResource:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
5
    pass
0 ignored issues
show
Unused Code introduced by
Unnecessary pass statement
Loading history...
6
    # TODO: certificate problem
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
7
    """"
8
    def test(self):
9
        # TODO incomplete coverage
10
        path = Path("tt.txt.gz")
11
        t = WebResource(
12
            "https://www.proteinatlas.org/download/normal_tissue.tsv.zip",
13
            "normal_tissue.tsv",
14
            path,
15
        )
16
        try:
17
            t.download(redownload=True)
18
19
            df = pd.read_csv(path, sep="\t")
20
            # note: this isn't a great test; the # of rows can change
21
            assert len(df) == 1118517
22
            assert t.datetime_downloaded()
23
            assert t.exists()
24
            t.delete()
25
            assert not t.exists()
26
        finally:
27
            if path.exists():
28
                try:
29
                    path.unlink()
30
                except OSError:
31
                    print(f"Warning: could not delete {path.absolute()}")
32
    """
0 ignored issues
show
Unused Code introduced by
This string statement has no effect and could be removed.
Loading history...
33
34
35
if __name__ == "__main__":
36
    pytest.main()
37