1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var CodeGradX = require('codegradxagent');
|
7 | var Agent = require('../codegradxvmauthor.js');
|
8 | var vmauthData = require('./vmauth-data.json');
|
9 |
|
10 | describe("CodeGradXVMauthorAgent process Batch", function () {
|
11 |
|
12 | it("should be loaded", function () {
|
13 | expect(Agent).toBeDefined();
|
14 | var agent = new CodeGradX.VMauthorAgent();
|
15 | expect(agent).toBeDefined();
|
16 | });
|
17 |
|
18 | function make_faildone (done) {
|
19 | return function faildone (reason) {
|
20 |
|
21 |
|
22 | fail(reason);
|
23 | done();
|
24 | };
|
25 | }
|
26 |
|
27 |
|
28 | var exercise1;
|
29 |
|
30 | it("should get hold of one exercise", function (done) {
|
31 | agent = new CodeGradX.VMauthorAgent();
|
32 | var faildone = make_faildone(done);
|
33 | var exerciseName = "org.example.li205.function.1";
|
34 | agent.process([
|
35 | "--user", vmauthData.login,
|
36 | "--password", vmauthData.password
|
37 | ]).then(function (user) {
|
38 | expect(user).toBeDefined();
|
39 | user.getCampaign('example').then(function (campaign) {
|
40 | expect(campaign).toBeDefined();
|
41 | expect(campaign.name).toBe('example');
|
42 | campaign.getExercise(exerciseName).then(function (exercise) {
|
43 | expect(exercise).toBeDefined();
|
44 | exercise1 = exercise;
|
45 |
|
46 | done();
|
47 | }, faildone);
|
48 | }, faildone);
|
49 | }, faildone);
|
50 | }, 10*1000);
|
51 |
|
52 | it("send a batch and get all jobs reports", function (done) {
|
53 | agent = new CodeGradX.VMauthorAgent();
|
54 | var faildone = make_faildone(done);
|
55 | agent.process([
|
56 | "-V",
|
57 | "--user", vmauthData.login,
|
58 | "--password", vmauthData.password,
|
59 | "--type", 'batch',
|
60 | "--stuff", 'spec/oefgc.tgz',
|
61 | "--exercise", exercise1.safecookie,
|
62 | "--offset", 30,
|
63 | "--timeout", 10,
|
64 | "--counter", 400,
|
65 | "--follow"
|
66 | ]).then(function (batch) {
|
67 | expect(batch).toBeDefined();
|
68 | expect(batch.finishedjobs).toBe(batch.totaljobs);
|
69 | console.log(batch);
|
70 | expect(batch.jobs.third).toBeDefined();
|
71 | done();
|
72 | }, faildone);
|
73 | }, 500*1000);
|
74 |
|
75 | });
|