Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sherlock-project
GitHub Repository: sherlock-project/sherlock
Path: blob/master/tests/test_manifest.py
761 views
1
import os
2
import json
3
import pytest
4
from jsonschema import validate
5
6
def test_validate_manifest_against_local_schema():
7
"""Ensures that the manifest matches the local schema, for situations where the schema is being changed."""
8
json_relative: str = '../sherlock_project/resources/data.json'
9
schema_relative: str = '../sherlock_project/resources/data.schema.json'
10
11
json_path: str = os.path.join(os.path.dirname(__file__), json_relative)
12
schema_path: str = os.path.join(os.path.dirname(__file__), schema_relative)
13
14
with open(json_path, 'r') as f:
15
jsondat = json.load(f)
16
with open(schema_path, 'r') as f:
17
schemadat = json.load(f)
18
19
validate(instance=jsondat, schema=schemadat)
20
21
22
@pytest.mark.online
23
def test_validate_manifest_against_remote_schema(remote_schema):
24
"""Ensures that the manifest matches the remote schema, so as to not unexpectedly break clients."""
25
json_relative: str = '../sherlock_project/resources/data.json'
26
json_path: str = os.path.join(os.path.dirname(__file__), json_relative)
27
28
with open(json_path, 'r') as f:
29
jsondat = json.load(f)
30
31
validate(instance=jsondat, schema=remote_schema)
32
33
# Ensure that the expected values are beind returned by the site list
34
@pytest.mark.parametrize("target_name,target_expected_err_type", [
35
('GitHub', 'status_code'),
36
('GitLab', 'message'),
37
])
38
def test_site_list_iterability (sites_info, target_name, target_expected_err_type):
39
assert sites_info[target_name]['errorType'] == target_expected_err_type
40
41