Debian Codegraph @

tests/search/v1/test_data.py

raw
1 import responses
2
3 from censys.search import SearchClient
4 from tests.utils import V1_URL, CensysTestCase
5
6 SERIES_JSON = {
7 "primary_series": "",
8 "raw_series": "",
9 }
10 VIEW_JSON = {
11 "description": (
12 "The Censys IPv4 dataset provides data about the services "
13 "(e.g., HTTP, SMTP, MySQL) running on all publicly-accessible IPv4 hosts."
14 ),
15 "results": {"historical": []},
16 }
17 RESULT_JSON = {"files": {"filename": {"file_type": "data"}}}
18 SERIES = "ipv4_2018"
19 RESULT = "20200818"
20
21
22 class CensysDataTest(CensysTestCase):
23 def setup_method(self):
24 self.setUpApi(SearchClient(self.api_id, self.api_secret).v1.data)
25
26 def test_get_series(self):
27 self.responses.add(
28 responses.GET,
29 f"{V1_URL}/data",
30 status=200,
31 json=SERIES_JSON,
32 )
33
34 series = self.api.get_series()
35 assert series == SERIES_JSON
36
37 def test_view_series(self):
38 self.responses.add(
39 responses.GET,
40 f"{V1_URL}/data/{SERIES}",
41 status=200,
42 json=VIEW_JSON,
43 )
44 res = self.api.view_series(SERIES)
45
46 assert res == VIEW_JSON
47
48 def test_view_result(self):
49 self.responses.add(
50 responses.GET,
51 f"{V1_URL}/data/{SERIES}/{RESULT}",
52 status=200,
53 json=RESULT_JSON,
54 )
55
56 res = self.api.view_result(SERIES, RESULT)
57
58 assert res == RESULT_JSON