def test_packages_json_schema(mocker, lsstsw_dir): """Validate the schema of the 'packages' json sub-document.""" # mock git.Repo in postqa.lsstsw so that a repo's active branch is master # and doesn't attempt to actually query the repo in the filesystem. mocker.patch('postqa.lsstsw.git.Repo') postqa.lsstsw.git.Repo.return_value.active_branch.name = 'master' lsstsw = Lsstsw(lsstsw_dir) job_json = lsstsw.json schema = load_squash_packages_schema() validate(job_json['packages'], schema)
def test_packages_json_schema(mocker, lsstsw_dir): """Validate the schema of the 'packages' json sub-document.""" # mock git.Repo in postqa.lsstsw so that a repo's active branch is master # and doesn't attempt to actually query the repo in the filesystem. mocker.patch('postqa.lsstsw.git.Repo') postqa.lsstsw.git.Repo.return_value.active_branch.name = 'master' lsstsw = Lsstsw(lsstsw_dir) job_json = lsstsw.json schema = load_squash_packages_schema() validate(job_json['packages'], schema)
def test_uri_validation(mocker, lsstsw_dir): mocker.patch('postqa.lsstsw.git.Repo') postqa.lsstsw.git.Repo.return_value.active_branch.name = 'master' lsstsw = Lsstsw(lsstsw_dir) job_json = lsstsw.json job_json['packages'][0]['git_url'] = 'blah' print(job_json['packages']) schema = load_squash_packages_schema() with pytest.raises(ValidationError): validate(job_json['packages'], schema)
def test_uri_validation(mocker, lsstsw_dir): mocker.patch('postqa.lsstsw.git.Repo') postqa.lsstsw.git.Repo.return_value.active_branch.name = 'master' lsstsw = Lsstsw(lsstsw_dir) job_json = lsstsw.json job_json['packages'][0]['git_url'] = 'blah' print(job_json['packages']) schema = load_squash_packages_schema() with pytest.raises(ValidationError): validate(job_json['packages'], schema)
def test_null_value_validation(job_json, schema): """Ensure schema validation does not allow values to be null.""" job_json['measurements'][0]['value'] = None with pytest.raises(ValidationError): validate(job_json['measurements'], schema)
def test_missing_metric_validation(job_json, schema): """Ensure schema validation picks up on missing 'metric'.""" del job_json['measurements'][0]['metric'] with pytest.raises(ValidationError): validate(job_json['measurements'], schema)
def test_measurements_schema(job_json, schema): """Validate the schema of `measurements` json sub-document.""" validate(job_json['measurements'], schema)