• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ProteinsWebTeam / interpro7-api / 1

18 Jun 2024 09:19AM UTC coverage: 25.541% (-68.5%) from 94.023%
1

push

github

web-flow
Merge pull request #147 from ProteinsWebTeam/set-sortable

sort by in sets

1 of 2 new or added lines in 1 file covered. (50.0%)

6742 existing lines in 50 files now uncovered.

2559 of 10019 relevant lines covered (25.54%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/functional_tests/tests.py
1
from functional_tests.base import FunctionalTest
2✔
2
from selenium.webdriver.common.by import By
2✔
3
import json
2✔
4
import re
2✔
5

6

7
class RESTRequestsTest(FunctionalTest):
2✔
8
    def test_request_entry_endpoint(self):
2✔
UNCOV
9
        self.browser.get(self.server_url + "/api/entry/?format=json")
×
UNCOV
10
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
UNCOV
11
        jsonp = json.loads(content)
×
12

UNCOV
13
        self.assertEqual(len(jsonp["entries"]), 5, "the output has exactly 5 keys")
×
UNCOV
14
        self.assertIn('"member_databases"', content)
×
UNCOV
15
        self.assertIn('"interpro"', content)
×
UNCOV
16
        self.assertIn('"unintegrated"', content)
×
17

UNCOV
18
        num_interpro = jsonp["entries"]["interpro"]
×
UNCOV
19
        self.assertEqual(
×
20
            num_interpro, 2, "the fixtures dataset only includes two interpro entry"
21
        )
22

UNCOV
23
        self.browser.get(self.server_url + "/api/entry/interpro?format=json")
×
UNCOV
24
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
25

UNCOV
26
        jsonp = json.loads(content)
×
27

UNCOV
28
        self.assertEqual(
×
29
            len(jsonp["results"]),
30
            num_interpro,
31
            "The response should have as many entries as reported in /entry ",
32
        )
33

UNCOV
34
        acc = jsonp["results"][0]["metadata"]["accession"]
×
UNCOV
35
        self.assertEqual(acc, "IPR001165")
×
UNCOV
36
        self.browser.get(
×
37
            self.server_url + "/api/entry/interpro/" + acc + "?format=json"
38
        )
UNCOV
39
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
40

UNCOV
41
        jsonp = json.loads(content)
×
UNCOV
42
        self.assertEqual(
×
43
            acc,
44
            jsonp["metadata"]["accession"],
45
            "The accession in the response object should be the same as reequested",
46
        )
UNCOV
47
        self.assertIn(
×
48
            "metadata",
49
            jsonp.keys(),
50
            "'metadata' should be one of the keys in the response",
51
        )
UNCOV
52
        self.assertTrue(
×
53
            isinstance(jsonp["metadata"]["go_terms"], list), "go_terms should be a list"
54
        )
55

UNCOV
56
        self.assertEqual(jsonp["metadata"]["counters"]["proteins"], 1)
×
57

58
    def test_request_protein_endpoint(self):
2✔
UNCOV
59
        self.browser.get(self.server_url + "/api/protein/?format=json")
×
UNCOV
60
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
61

UNCOV
62
        jsonp = json.loads(content)
×
63

UNCOV
64
        self.assertEqual(len(jsonp["proteins"]), 3, "the output has exactly 3 keys")
×
65

UNCOV
66
        self.assertIn('"uniprot"', content)
×
67

UNCOV
68
        num_uniprot = jsonp["proteins"]["uniprot"]
×
UNCOV
69
        self.assertEqual(
×
70
            num_uniprot, 5, "the TEST dataset only includes 5 uniprot entries"
71
        )
72

UNCOV
73
        self.browser.get(self.server_url + "/api/protein/uniprot?format=json")
×
UNCOV
74
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
75

UNCOV
76
        jsonp = json.loads(content)
×
77

UNCOV
78
        self.assertEqual(
×
79
            len(jsonp["results"]),
80
            num_uniprot,
81
            "The response should have as many entries as reported in /entry ",
82
        )
UNCOV
83
        acc = jsonp["results"][0]["metadata"]["accession"]
×
84

UNCOV
85
        self.browser.get(
×
86
            self.server_url + "/api/protein/uniprot/" + acc + "?format=json"
87
        )
UNCOV
88
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
89

UNCOV
90
        jsonp = json.loads(content)
×
UNCOV
91
        self.assertEqual(
×
92
            acc,
93
            jsonp["metadata"]["accession"],
94
            "The accession in the response object should be the same as reequested",
95
        )
UNCOV
96
        self.assertIn(
×
97
            "category",
98
            jsonp["metadata"]["go_terms"][0],
99
            "the key is part of the go_terms and has been parsed OK",
100
        )
101

UNCOV
102
        self.browser.get(
×
103
            self.server_url
104
            + "/api/protein/uniprot/"
105
            + jsonp["metadata"]["id"]
106
            + "?format=json"
107
        )
UNCOV
108
        content2 = self.browser.find_element(By.TAG_NAME, "body").text
×
109

UNCOV
110
        jsonp2 = json.loads(content2)
×
UNCOV
111
        self.assertEqual(
×
112
            jsonp,
113
            jsonp2,
114
            "The recovered JSON object when quierying by accession should be the same than the "
115
            "correspondent search by ID",
116
        )
117

118
    def test_request_to_api_frontend(self):
2✔
UNCOV
119
        url = "/api/entry/"
×
UNCOV
120
        self.browser.get(self.server_url + url)
×
121

UNCOV
122
        req_info = self.browser.find_element(By.CSS_SELECTOR, ".request-info").text
×
123

UNCOV
124
        self.assertIn("GET", req_info)
×
UNCOV
125
        self.assertIn(url, req_info)
×
126

UNCOV
127
        response = self.browser.find_element(By.CSS_SELECTOR, ".response-info").text
×
UNCOV
128
        match = re.search("[\{\[]", response)
×
UNCOV
129
        json_frontend = json.loads(response[match.start() :])
×
130

UNCOV
131
        self.browser.find_element(By.CSS_SELECTOR, ".format-selection button").click()
×
UNCOV
132
        self.click_link_and_wait(
×
133
            self.browser.find_element(By.CSS_SELECTOR, ".js-tooltip.format-option")
134
        )
135

UNCOV
136
        content = self.browser.find_element(By.TAG_NAME, "body").text
×
137

UNCOV
138
        jsonp = json.loads(content)
×
139

UNCOV
140
        self.assertEqual(json_frontend, jsonp)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc