From 94d5d1a32d5bed391c43721bc63205c06ec792dc Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 17 Apr 2020 14:16:24 -0400 Subject: [PATCH] cleaning up --- .gitignore | 2 +- cypress/scripts/install.sh | 3 -- public/manifest.webapp | 2 +- src/config/serverConfig.dev.json | 2 +- src/config/workflows.json | 1 + testData/.idea/.gitignore | 2 + .../inspectionProfiles/profiles_settings.xml | 6 +++ testData/.idea/misc.xml | 4 ++ testData/.idea/modules.xml | 8 ++++ testData/.idea/scripts.iml | 8 ++++ testData/.idea/vcs.xml | 6 +++ {cypress/scripts => testData}/api.py | 0 testData/cors/api.py | 44 +++++++++++++++++++ testData/cors/cors.py | 5 +++ .../scripts => testData}/dataEntry/data.sql | 0 .../dataEntry/getData.sql | 0 .../scripts => testData}/dataStore/api.py | 0 .../dataStore/dataStore.py | 2 + testData/install.sh | 18 ++++++++ .../mechanism => testData/mechanisms}/api.py | 0 .../mechanisms}/submitMechanisms.py | 2 + {cypress/scripts => testData}/users/api.py | 0 .../scripts => testData}/users/fetch_users.py | 0 .../users/persistUsers.py | 2 + .../scripts => testData}/users/updateUsers.sh | 0 .../scripts => testData}/users/users.json | 0 26 files changed, 111 insertions(+), 6 deletions(-) delete mode 100644 cypress/scripts/install.sh create mode 100644 testData/.idea/.gitignore create mode 100644 testData/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 testData/.idea/misc.xml create mode 100644 testData/.idea/modules.xml create mode 100644 testData/.idea/scripts.iml create mode 100644 testData/.idea/vcs.xml rename {cypress/scripts => testData}/api.py (100%) create mode 100644 testData/cors/api.py create mode 100755 testData/cors/cors.py rename {cypress/scripts => testData}/dataEntry/data.sql (100%) rename {cypress/scripts => testData}/dataEntry/getData.sql (100%) rename {cypress/scripts => testData}/dataStore/api.py (100%) rename cypress/scripts/dataStore/fixDataStore.py => testData/dataStore/dataStore.py (96%) mode change 100644 => 100755 create mode 100755 testData/install.sh rename {cypress/scripts/mechanism => testData/mechanisms}/api.py (100%) rename {cypress/scripts/mechanism => testData/mechanisms}/submitMechanisms.py (98%) mode change 100644 => 100755 rename {cypress/scripts => testData}/users/api.py (100%) rename {cypress/scripts => testData}/users/fetch_users.py (100%) rename cypress/scripts/users/persist_users.py => testData/users/persistUsers.py (96%) mode change 100644 => 100755 rename {cypress/scripts => testData}/users/updateUsers.sh (100%) rename {cypress/scripts => testData}/users/users.json (100%) diff --git a/.gitignore b/.gitignore index ad53083..46becda 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,4 @@ cypress/scripts/mechanism/api.pyc cypress/scripts/users/api.pyc cypress/scripts/dataStore/__pycache__/ cypress/scripts/dataStore/api.pyc - +*.pyc diff --git a/cypress/scripts/install.sh b/cypress/scripts/install.sh deleted file mode 100644 index ec062f6..0000000 --- a/cypress/scripts/install.sh +++ /dev/null @@ -1,3 +0,0 @@ -python dataStore/fixDataStore.py -python mechanism/submitMechanisms.py -(cd users; python persist_users.py) diff --git a/public/manifest.webapp b/public/manifest.webapp index 98019c0..6b10308 100644 --- a/public/manifest.webapp +++ b/public/manifest.webapp @@ -3,7 +3,7 @@ "default_locale": "en", "appType": "APP", "name": "Data Approval", - "version": "2.0.2", + "version": "2.0.5", "description": "DATIM Mechanisms Approval App", "developer": { "name": "Jakub Flaska", diff --git a/src/config/serverConfig.dev.json b/src/config/serverConfig.dev.json index fc45a91..cf0817a 100644 --- a/src/config/serverConfig.dev.json +++ b/src/config/serverConfig.dev.json @@ -1,5 +1,5 @@ { - "baseUrl": "https://test.datim.org/", + "baseUrl": "https://sandbox.er.datim.org/", "sqlViewId": "rQZnEgCAhuI", "apiVersion": "30" } \ No newline at end of file diff --git a/src/config/workflows.json b/src/config/workflows.json index 351e9f7..7b934fd 100644 --- a/src/config/workflows.json +++ b/src/config/workflows.json @@ -1,5 +1,6 @@ [ {"name": "ER Expenditures FYOct", "id": "WUD8TApgOu1", "type": "ER"}, + {"name": "Workplan Budgets FYOct", "id": "e8F8M6leZjj", "type": "ER"}, {"name": "MER Results", "id": "RwNpkAM7Hw7", "type": "MER"}, {"name": "MER Targets", "id": "TAjCBkG6hl6", "type": "MER"} ] \ No newline at end of file diff --git a/testData/.idea/.gitignore b/testData/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/testData/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/testData/.idea/inspectionProfiles/profiles_settings.xml b/testData/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/testData/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/testData/.idea/misc.xml b/testData/.idea/misc.xml new file mode 100644 index 0000000..a2e120d --- /dev/null +++ b/testData/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/testData/.idea/modules.xml b/testData/.idea/modules.xml new file mode 100644 index 0000000..bb83e26 --- /dev/null +++ b/testData/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/testData/.idea/scripts.iml b/testData/.idea/scripts.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/testData/.idea/scripts.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/testData/.idea/vcs.xml b/testData/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/testData/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cypress/scripts/api.py b/testData/api.py similarity index 100% rename from cypress/scripts/api.py rename to testData/api.py diff --git a/testData/cors/api.py b/testData/cors/api.py new file mode 100644 index 0000000..73ab7c8 --- /dev/null +++ b/testData/cors/api.py @@ -0,0 +1,44 @@ +import requests +import os + +api = os.environ['DHIS_BASEURL'] + '/api/' +credentials = (os.environ['DHIS_USERNAME'], os.environ['DHIS_PASSWORD']) + +res = requests.get(api + 'resources.json', auth=credentials) +if res.json()['resources'][0]: + print('Connected to DHIS2: ' + api) +else: + raise Exception("Cannot connect to DHIS2: " + api) + +def get(url, params): + res = requests.get(api + url, auth=credentials, params=params) + process_status_code(res, 'get') + return res.json() + +def delete(url): + res = requests.delete(api + url, auth=credentials) + process_status_code(res, 'delete') + + +def post(url, body): + res = requests.post(api + url, auth=credentials, json=body) + process_status_code(res, 'post') + +def formPost(url, data): + headers = {'Content-Type': 'application/x-www-form-urlencoded'} + res = requests.post(api + url, auth=credentials, data=data, headers=headers) + process_status_code(res, 'post') + +def put(url, body): + res = requests.put(api + url, auth=credentials, json=body) + process_status_code(res, 'put') + +def process_status_code(response, method): + if response.status_code in range(200,210): + print(method + ' to url ' + response.url + ' successful') + else: + print(method + ' to url ' + response.url + ' failed') + try: + print(response.json()) + except: + print(response) \ No newline at end of file diff --git a/testData/cors/cors.py b/testData/cors/cors.py new file mode 100755 index 0000000..b680865 --- /dev/null +++ b/testData/cors/cors.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import api + +api.post('configuration/corsWhitelist', ["http://localhost:3000","http://localhost:3001","http://localhost:3002","http://localhost:3003","http://localhost:3004","http://localhost:3005"]) \ No newline at end of file diff --git a/cypress/scripts/dataEntry/data.sql b/testData/dataEntry/data.sql similarity index 100% rename from cypress/scripts/dataEntry/data.sql rename to testData/dataEntry/data.sql diff --git a/cypress/scripts/dataEntry/getData.sql b/testData/dataEntry/getData.sql similarity index 100% rename from cypress/scripts/dataEntry/getData.sql rename to testData/dataEntry/getData.sql diff --git a/cypress/scripts/dataStore/api.py b/testData/dataStore/api.py similarity index 100% rename from cypress/scripts/dataStore/api.py rename to testData/dataStore/api.py diff --git a/cypress/scripts/dataStore/fixDataStore.py b/testData/dataStore/dataStore.py old mode 100644 new mode 100755 similarity index 96% rename from cypress/scripts/dataStore/fixDataStore.py rename to testData/dataStore/dataStore.py index 0c6a48a..a8b3a0e --- a/cypress/scripts/dataStore/fixDataStore.py +++ b/testData/dataStore/dataStore.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import api diff --git a/testData/install.sh b/testData/install.sh new file mode 100755 index 0000000..85bd302 --- /dev/null +++ b/testData/install.sh @@ -0,0 +1,18 @@ +#!/usr/bin/bash + +section(){ + echo ---------------------------- + echo $1 +} + +section Users \> Adding test user accounts +(cd users && ./persistUsers.py) + +section DataStore \> Opening data entry periods for dedupes +(cd dataStore && ./dataStore.py) + +section Mechanisms \> Submit mechanisms to expected level +(cd mechanisms && ./submitMechanisms.py) + +section CORS \> Whitelist localhost +(cd cors && ./cors.py) \ No newline at end of file diff --git a/cypress/scripts/mechanism/api.py b/testData/mechanisms/api.py similarity index 100% rename from cypress/scripts/mechanism/api.py rename to testData/mechanisms/api.py diff --git a/cypress/scripts/mechanism/submitMechanisms.py b/testData/mechanisms/submitMechanisms.py old mode 100644 new mode 100755 similarity index 98% rename from cypress/scripts/mechanism/submitMechanisms.py rename to testData/mechanisms/submitMechanisms.py index 7167d98..9f9f9bb --- a/cypress/scripts/mechanism/submitMechanisms.py +++ b/testData/mechanisms/submitMechanisms.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import api diff --git a/cypress/scripts/users/api.py b/testData/users/api.py similarity index 100% rename from cypress/scripts/users/api.py rename to testData/users/api.py diff --git a/cypress/scripts/users/fetch_users.py b/testData/users/fetch_users.py similarity index 100% rename from cypress/scripts/users/fetch_users.py rename to testData/users/fetch_users.py diff --git a/cypress/scripts/users/persist_users.py b/testData/users/persistUsers.py old mode 100644 new mode 100755 similarity index 96% rename from cypress/scripts/users/persist_users.py rename to testData/users/persistUsers.py index ce48dad..a290e82 --- a/cypress/scripts/users/persist_users.py +++ b/testData/users/persistUsers.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import api import json import os diff --git a/cypress/scripts/users/updateUsers.sh b/testData/users/updateUsers.sh similarity index 100% rename from cypress/scripts/users/updateUsers.sh rename to testData/users/updateUsers.sh diff --git a/cypress/scripts/users/users.json b/testData/users/users.json similarity index 100% rename from cypress/scripts/users/users.json rename to testData/users/users.json