Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Remove tests depending on removed test data #623

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions scripts/v2-test-data-config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"generated-test-data": [
{
"source": "/v2/ontologies/all-ontology-metadata-response.json",
"destination": "./test/data/api/v2/ontologies/all-ontology-metadata-response.json"
},
{
"source": "/v2/ontologies/knora-api-ontology.json",
"destination": "./test/data/api/v2/ontologies/knora-api-ontology.json"
Expand All @@ -12,22 +8,10 @@
"source": "/v2/ontologies/anything-ontology.json",
"destination": "./test/data/api/v2/ontologies/anything-ontology.json"
},
{
"source": "/v2/ontologies//minimal-ontology.json",
"destination": "./test/data/api/v2/ontologies/minimal-ontology.json"
},
{
"source": "/v2/ontologies/incunabula-ontology.json",
"destination": "./test/data/api/v2/ontologies/incunabula-ontology.json"
},
{
"source": "/v2/ontologies/get-ontologies-project-anything-response.json",
"destination": "./test/data/api/v2/ontologies/get-ontologies-project-anything-response.json"
},
{
"source": "/v2/ontologies/get-ontologies-project-incunabula-response.json",
"destination": "./test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json"
},
{
"source": "/v2/ontologies/create-empty-foo-ontology-request.json",
"destination": "./test/data/api/v2/ontologies/create-empty-foo-ontology-request.json"
Expand Down
98 changes: 0 additions & 98 deletions src/api/v2/ontology/ontologies-endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,6 @@ describe("OntologiesEndpoint", () => {
jasmine.Ajax.uninstall();
});

describe("Method getOntologiesMetadata", () => {

it("should return metadata about all ontologies", done => {

knoraApiConnection.v2.onto.getOntologiesMetadata().subscribe(
(response: OntologiesMetadata) => {
expect(response.ontologies.length).toEqual(15);
expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2");
done();
}
);

const request = jasmine.Ajax.requests.mostRecent();

const ontoMetadata = require("../../../../test/data/api/v2/ontologies/all-ontology-metadata-response.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(ontoMetadata)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/metadata");

expect(request.method).toEqual("GET");

});

});

describe("Method getOntology", () => {

it("should return an ontology", done => {
Expand Down Expand Up @@ -188,56 +162,6 @@ describe("OntologiesEndpoint", () => {

});

it("should return a very simple project ontology", done => {

knoraApiConnection.v2.onto.getOntology("http://0.0.0.0:3333/ontology/0001/minimal/v2").subscribe(
(response: ReadOntology) => {

expect(response.id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2");
expect(response.label).toEqual("A minimal ontology");

expect(response.dependsOnOntologies.size).toEqual(1);
expect(response.dependsOnOntologies.has("http://api.knora.org/ontology/knora-api/v2")).toBeTruthy();

done();
});

const request = jasmine.Ajax.requests.mostRecent();

const onto = require("../../../../test/data/api/v2/ontologies/minimal-ontology.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(onto)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/allentities/http%3A%2F%2F0.0.0.0%3A3333%2Fontology%2F0001%2Fminimal%2Fv2");

expect(request.method).toEqual("GET");

});

it("should return an ontology with labels and comments in all languages", done => {

knoraApiConnection.v2.onto.getOntology("http://0.0.0.0:3333/ontology/0001/minimal/v2", true).subscribe(
(response: ReadOntology) => {

expect(response.getPropertyDefinitionsByType(ResourcePropertyDefinitionWithAllLanguages).length).toEqual(1);

expect(response.getPropertyDefinitionsByType(ResourcePropertyDefinitionWithAllLanguages)[0].labels[0].value).toEqual("has name");

done();
});

const request = jasmine.Ajax.requests.mostRecent();

const onto = require("../../../../test/data/api/v2/manually-generated/minimal-ontology-with-all-languages-expanded.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(onto)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/allentities/http%3A%2F%2F0.0.0.0%3A3333%2Fontology%2F0001%2Fminimal%2Fv2?allLanguages=true");

expect(request.method).toEqual("GET");

});

});

describe("Method getOntologiesByProjectIri", () => {
Expand Down Expand Up @@ -287,28 +211,6 @@ describe("OntologiesEndpoint", () => {

});

it("should return all ontologies from 'incunabula' project", done => {

knoraApiConnection.v2.onto.getOntologiesByProjectIri("http://rdfh.ch/projects/0803").subscribe(
(response: OntologiesMetadata) => {
expect(response.ontologies.length).toEqual(1);
expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0803/incunabula/v2");
done();
}
);

const request = jasmine.Ajax.requests.mostRecent();

const ontoMetadata = require("../../../../test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json");

request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(ontoMetadata)));

expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/metadata/http%3A%2F%2Frdfh.ch%2Fprojects%2F0803");

expect(request.method).toEqual("GET");

});

});

describe("Method createOntology", () => {
Expand Down
17 changes: 2 additions & 15 deletions test/data/api/v2/mock-ontology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { ResourceClassDefinition } from "../../../../src/models/v2/ontologies/re
import { ResourcePropertyDefinition } from "../../../../src/models/v2/ontologies/resource-property-definition";
import { StandoffClassDefinition } from "../../../../src/models/v2/ontologies/standoff-class-definition";
import { SystemPropertyDefinition } from "../../../../src/models/v2/ontologies/system-property-definition";
import ontologiesMetadata from "../v2/ontologies/all-ontology-metadata-response-expanded.json";
import anythingOntologyExpanded from "../v2/ontologies/anything-ontology-expanded.json";
import minimalOntologyExpanded from "../v2/ontologies/minimal-ontology-expanded.json";
import incunabulaOntologyExpanded from "../v2/ontologies/incunabula-ontology-expanded.json";
import knoraApiOntologyExpanded from "../v2/ontologies/knora-api-ontology-expanded.json";

export namespace MockOntology {
Expand All @@ -27,10 +24,6 @@ export namespace MockOntology {
PropertyMatchingRule.CASE_STRICT
);

export const mockOntologiesMetadata = (): OntologiesMetadata => {
return jsonConvert.deserializeObject(ontologiesMetadata, OntologiesMetadata);
};

export const mockReadOntology = (ontoIri: string): ReadOntology => {

let ontologyJsonld: any;
Expand All @@ -44,10 +37,6 @@ export namespace MockOntology {
ontologyJsonld = anythingOntologyExpanded;
break;
}
case "http://0.0.0.0:3333/ontology/0001/minimal/v2": {
ontologyJsonld = minimalOntologyExpanded;
break;
}
default: {
throw new Error("Ontology not supported: " + ontoIri);
}
Expand Down Expand Up @@ -105,13 +94,11 @@ export namespace MockOntology {

const anythingOntology: any = anythingOntologyExpanded;
const knoraApiOntology: any = knoraApiOntologyExpanded;
const incunabulaOntology: any = incunabulaOntologyExpanded;

const knoraApiEntities = (knoraApiOntology as { [index: string]: object[] })["@graph"];
const anythingEntities = (anythingOntology as { [index: string]: object[] })["@graph"];
const incunabulaEntities = (incunabulaOntology as { [index: string]: object[] })["@graph"];

const entities = knoraApiEntities.concat(anythingEntities).concat(incunabulaEntities);
const entities = knoraApiEntities.concat(anythingEntities);

// Convert resource classes
entities.filter(OntologyConversionUtil.filterResourceClassDefinitions)
Expand Down Expand Up @@ -151,7 +138,7 @@ export namespace MockOntology {
});

return new ResourceClassAndPropertyDefinitions(
{[resClassIri]: new ResourceClassDefinitionWithPropertyDefinition(tmpClasses[resClassIri], tmpProps)},
{ [resClassIri]: new ResourceClassDefinitionWithPropertyDefinition(tmpClasses[resClassIri], tmpProps) },
tmpProps
);

Expand Down
Loading