1 | import CONFIGURATION_1 from './data/configuration_1.json';
|
2 |
|
3 | import CONFIGURATION_1_OPERATIONS_1 from './data/configuration_1_operations_1.json';
|
4 | import craftai from '../src';
|
5 |
|
6 | const CONFIGURATION_1_OPERATIONS_1_TO = _.last(CONFIGURATION_1_OPERATIONS_1).timestamp;
|
7 |
|
8 | describe('client.computeAgentDecision(<agentId>, <timestamp>, <context>)', function() {
|
9 | let client;
|
10 | let agent;
|
11 | const agentId = `compute_agent_decision_${RUN_ID}`;
|
12 |
|
13 | before(function() {
|
14 | client = craftai(CRAFT_CFG);
|
15 | expect(client).to.be.ok;
|
16 | });
|
17 |
|
18 | beforeEach(function() {
|
19 | return client.deleteAgent(agentId)
|
20 | .then(() => client.createAgent(CONFIGURATION_1, agentId))
|
21 | .then((createdAgent) => {
|
22 | expect(createdAgent).to.be.ok;
|
23 | agent = createdAgent;
|
24 | return client.addAgentContextOperations(agent.id, CONFIGURATION_1_OPERATIONS_1);
|
25 | });
|
26 | });
|
27 |
|
28 | afterEach(function() {
|
29 | return client.deleteAgent(agentId);
|
30 | });
|
31 |
|
32 | it('should succeed when using valid parameters', function() {
|
33 | return client.computeAgentDecision(agent.id, CONFIGURATION_1_OPERATIONS_1_TO, {
|
34 | presence: 'none',
|
35 | lightIntensity: 0.1
|
36 | })
|
37 | .then((decision) => {
|
38 | expect(decision).to.be.ok;
|
39 | expect(decision.output.lightbulbColor.predicted_value).to.be.equal('black');
|
40 | });
|
41 | });
|
42 | it('should succeed when using valid parameters (context override)', function() {
|
43 | return client.computeAgentDecision(agent.id, CONFIGURATION_1_OPERATIONS_1_TO, {
|
44 | presence: 'none',
|
45 | lightIntensity: 1
|
46 | }, {
|
47 | lightIntensity: 0.1
|
48 | })
|
49 | .then((decision) => {
|
50 | expect(decision).to.be.ok;
|
51 | expect(decision.output.lightbulbColor.predicted_value).to.be.equal('black');
|
52 | });
|
53 | });
|
54 | });
|