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