Merge ~mihal277/dpcs:tests into dpcs:master

Proposed by mihal277
Status: Needs review
Proposed branch: ~mihal277/dpcs:tests
Merge into: dpcs:master
Diff against target: 119 lines (+88/-1)
5 files modified
dev/null (+0/-1)
tests/.gitignore (+1/-0)
tests/acceptance_test.sh (+50/-0)
tests/readme.md (+6/-0)
tests/test_api.py (+31/-0)
Reviewer Review Type Date Requested Status
Marek BardoĊ„ski Pending
Review via email: mp+288230@code.launchpad.net
To post a comment you must log in.

Unmerged commits

ee4f771... by mihal277

Modified test_api, added acceptance test and readme file

623cb7e... by mihal277

Basic syntax for testing API

53abe67... by mihal277

deleted readme.md file from the main directory

6eae588... by mihal277

added tests folder

5c23a73... by mihal277

Initial commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/readme.md b/readme.md
2deleted file mode 100644
3index 9c558e3..0000000
4--- a/readme.md
5+++ /dev/null
6@@ -1 +0,0 @@
7-.
8diff --git a/tests/.gitignore b/tests/.gitignore
9new file mode 100644
10index 0000000..016f806
11--- /dev/null
12+++ b/tests/.gitignore
13@@ -0,0 +1 @@
14+/tests/
15diff --git a/tests/acceptance_test.sh b/tests/acceptance_test.sh
16new file mode 100755
17index 0000000..3d408d5
18--- /dev/null
19+++ b/tests/acceptance_test.sh
20@@ -0,0 +1,50 @@
21+#!/bin/bash
22+
23+declare -a arr PACK=(
24+ "prettytable"
25+ "delorean"
26+ "snowballstemmer"
27+ "wget"
28+ "sh"
29+ "fuzzywuzzy"
30+ "progressbar"
31+ "uuid"
32+ "bashplotlib"
33+)
34+
35+echo Start tests
36+installed=0
37+failed=0
38+correct=0
39+
40+RED='\033[0;31m'
41+GREEN='\033[0;32m'
42+NC='\033[0m'
43+
44+for i in "${PACK[@]}"
45+do
46+ echo "Check: $i"
47+ python -c "import $i" &> /dev/null
48+ if [ $? -eq 0 ]; then
49+ echo "$i already installed"
50+ ((installed++))
51+ else
52+ python -c "import $i" &> /dev/null
53+ if [ $? -eq 0 ]; then
54+ printf "${GREEN}$i installed correctly${NC}\n"
55+ ((correct++))
56+ else
57+ printf "${RED}$i FAILED${NC}\n"
58+ ((failed++))
59+ fi
60+ fi
61+done
62+
63+printf "installed: $installed, ${GREEN}correct: $correct${NC}, ${RED}failed: $failed${NC}\n"
64+
65+if [ $failed -eq 0 ]
66+then
67+ exit 0
68+else
69+ exit 1
70+fi
71diff --git a/tests/readme.md b/tests/readme.md
72new file mode 100644
73index 0000000..50bcad8
74--- /dev/null
75+++ b/tests/readme.md
76@@ -0,0 +1,6 @@
77+The acceptance test runs several python scripts that simply import some uninstalled libraries.
78+The Data Powered Crash Solver is supposed to install those missing libraries. After the DPCS has installed the library, the test runs the python script again to find out if the library was installed correctly.
79+
80+Note that the tests assume that the DPCS works automatically.
81+
82+Test_api is a temporary file that perhaps will be used to create complete unit tests of API.
83diff --git a/tests/test_api.py b/tests/test_api.py
84new file mode 100644
85index 0000000..455778d
86--- /dev/null
87+++ b/tests/test_api.py
88@@ -0,0 +1,31 @@
89+import requests, json, collections
90+
91+# api adress
92+api_url = "http://private-a6e53-dpcs.apiary-mock.com"
93+
94+
95+class MyClient:
96+ service_url = api_url
97+ def do_get(self, suffix):
98+ return requests.get(self.service_url + suffix).json()
99+
100+
101+client = MyClient()
102+# print(client.do_get("/vd1/crash-reports/1"))
103+service_url = api_url
104+
105+def do_get(self, suffix):
106+ return requests.get(self.service_url + suffix).json()
107+
108+data = {}
109+data['crash-reports'] = 'vd1/crash-reports/'
110+data['crash-groups'] = 'vd1/crash-groups/'
111+data['solutions'] = 'vd1/solutions/'
112+json_test = json.dumps(data)
113+
114+client = MyClient()
115+json_from_api = client.do_get("/vd1/paths/")
116+
117+json_test_object = json.loads(json_test)
118+
119+assert json_test_object == json_from_api

Subscribers

People subscribed via source and target branches

to all changes: