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

Готовая лаба #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
94 changes: 94 additions & 0 deletions src/rdf4j-tests/sparql-post-without-context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
describe('test Get', function() {
const data = '<http://exampleSub> <http://exampleSub> 69';
var params =
'action=exec&' +
'queryLn=SPARQL&' +
'query=' +
encodeURIComponent(
'PREFIX foaf: <https://agentlab.ru/rdf4j-workbench/repositories> ' + 'SELECT ?Subject ' + 'WHERE{ ' + data + '}',
) +
'&' +
'limit_query=100&' +
'infer=true&';

it('insert data to rdf repository without context', async () => {
var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params;
//проверка до добавления
var dataSel = await fetch(urlprefix, {
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
}).then((r) => r.json());
expect(dataSel.results.bindings.length).toEqual(0);

//добавление
urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/update';
var result = await fetch(urlprefix, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
body: 'update=' + encodeURIComponent('INSERT DATA' + '{' + data + '}'),
}).then((r) => {
console.log(r);
expect(r).toBeInstanceOf(Response);
expect(r['status']).toEqual(200);
return r;
});
});

it('check data after insert to rdf repository without context', async () => {
//проверка после
var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params;
var dataSel = await fetch(urlprefix, {
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
}).then((r) => r.json());
expect(dataSel.results.bindings.length).toBeGreaterThan(0);
});

it('delete data to rdf repository without context', async () => {
var urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/query' + '?' + params;
//проверка до
var dataSel = await fetch(urlprefix, {
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
}).then((r) => r.json());
expect(dataSel.results.bindings.length).toBeGreaterThan(0);

//удаление
urlprefix = 'https://agentlab.ru/rdf4j-workbench/repositories/rtrtrtr/update';
var result = await fetch(urlprefix, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
body: 'update=' + encodeURIComponent('DELETE DATA' + '{' + data + '}'),
}).then((r) => {
console.log(r);
expect(r).toBeInstanceOf(Response);
expect(r['status']).toEqual(200);
return r;
});

//проверка после
dataSel = await fetch(urlprefix, {
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/sparql-results+json',
},
}).then((r) => r.json());
expect(dataSel.results.bindings.length).toEqual(0);
});
});