From f9dd6dc712868f2981f1c21cd4f3e7d20209747d Mon Sep 17 00:00:00 2001 From: Daniil Efremov Date: Fri, 7 Oct 2016 15:22:04 +0700 Subject: [PATCH] query CK crowdnode status from CK machine module #12 - add "cfg" key to response --- src/ck-crowdnode-server.c | 4 +++- tests/test_state.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ck-crowdnode-server.c b/src/ck-crowdnode-server.c index a3a5fe4..9520774 100644 --- a/src/ck-crowdnode-server.c +++ b/src/ck-crowdnode-server.c @@ -1059,7 +1059,9 @@ void processShell(int sock, cJSON* commandJSON, char *baseDir) { void processState(int sock, const char *baseDir) { cJSON *resultJSON = cJSON_CreateObject(); cJSON_AddItemToObject(resultJSON, "return", cJSON_CreateString("0")); - cJSON_AddItemToObject(resultJSON, JSON_CONFIG_PARAM_PATH_TO_FILES, cJSON_CreateString(strdup(baseDir))); + cJSON *cfgJSON = cJSON_CreateObject(); + cJSON_AddItemToObject(cfgJSON, JSON_CONFIG_PARAM_PATH_TO_FILES, cJSON_CreateString(strdup(baseDir))); + cJSON_AddItemToObject(resultJSON, "cfg", cfgJSON); sendJson(sock, resultJSON); cJSON_Delete(resultJSON); } diff --git a/tests/test_state.py b/tests/test_state.py index f960368..befef71 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -12,8 +12,9 @@ class TestPushPull(unittest.TestCase): def test_state(self): r = access_test_repo({'action': 'state'}) - self.assertIn('path_to_files', r) - self.assertEqual(files_dir, r['path_to_files']) + cfg_ = r['cfg'] + self.assertIn('path_to_files', cfg_) + self.assertEqual(files_dir, cfg_['path_to_files']) self.assertIn('return', r) self.assertEqual(0, r['return'])