Passed
Push — main ( bfa577...eb6882 )
by Douglas
04:37
created

TestIndicationSearch.test_find()   A

Complexity

Conditions 1

Size

Total Lines 22
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 20
nop 1
dl 0
loc 22
rs 9.4
c 0
b 0
f 0
1
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
introduced by
Missing module docstring
Loading history...
2
3
from mandos.cli import Commands, Searcher
4
from mandos.model.chembl_api import ChemblApi
5
from chembl_webresource_client.new_client import new_client as Chembl
0 ignored issues
show
introduced by
Unable to import 'chembl_webresource_client.new_client'
Loading history...
6
from mandos.search.chembl.indication_search import IndicationSearch
0 ignored issues
show
introduced by
Imports from package mandos are not grouped
Loading history...
7
8
from .. import get_test_resource
9
10
11
class TestIndicationSearch:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
12
    def test_find(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
introduced by
Missing function or method docstring
Loading history...
13
        df, triples = Commands.trials(get_test_resource("inchis.txt"))
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
14
        assert len(df) == 6
15
        assert len(triples) == 6
16
        assert {t.compound_name.lower() for t in triples} == {"alprazolam"}
17
        assert {t.object_id for t in triples} == {
18
            "D012559",
19
            "D016584",
20
            "D003704",
21
            "D001008",
22
            "D001007",
23
            "D003866",
24
        }
25
        assert {t.object_name.lower() for t in triples} == {
26
            "schizophrenia",
27
            "panic disorder",
28
            "dementia",
29
            "anxiety",
30
            "depressive disorder",
31
            "anxiety disorders",
32
        }
33
        assert {t.predicate for t in triples} == {"phase-4 indication", "phase-3 indication"}
34
35
    def test_cocaine_hcl(self):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
36
        api = ChemblApi.wrap(Chembl)
37
        df, triples = Searcher(IndicationSearch(api, min_phase=3)).search_for(["CHEMBL529437"])
0 ignored issues
show
Coding Style Naming introduced by
Variable name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
38
        assert len(df) == 1
39
        assert len(triples) == 1
40
        assert triples[0].compound_name.lower() == "cocaine"
41
        assert triples[0].compound_id == "CHEMBL370805"
42
        assert triples[0].object_id == "D000758"
43
        assert triples[0].object_name == "Anesthesia"
44
        assert triples[0].predicate == "phase-4 indication"
45
46
47
if __name__ == "__main__":
48
    pytest.main()
49