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
diff --git a/readme.md b/readme.md
0deleted file mode 1006440deleted file mode 100644
index 9c558e3..0000000
--- a/readme.md
+++ /dev/null
@@ -1 +0,0 @@
1.
diff --git a/tests/.gitignore b/tests/.gitignore
2new file mode 1006440new file mode 100644
index 0000000..016f806
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
1/tests/
diff --git a/tests/acceptance_test.sh b/tests/acceptance_test.sh
0new file mode 1007552new file mode 100755
index 0000000..3d408d5
--- /dev/null
+++ b/tests/acceptance_test.sh
@@ -0,0 +1,50 @@
1#!/bin/bash
2
3declare -a arr PACK=(
4 "prettytable"
5 "delorean"
6 "snowballstemmer"
7 "wget"
8 "sh"
9 "fuzzywuzzy"
10 "progressbar"
11 "uuid"
12 "bashplotlib"
13)
14
15echo Start tests
16installed=0
17failed=0
18correct=0
19
20RED='\033[0;31m'
21GREEN='\033[0;32m'
22NC='\033[0m'
23
24for i in "${PACK[@]}"
25do
26 echo "Check: $i"
27 python -c "import $i" &> /dev/null
28 if [ $? -eq 0 ]; then
29 echo "$i already installed"
30 ((installed++))
31 else
32 python -c "import $i" &> /dev/null
33 if [ $? -eq 0 ]; then
34 printf "${GREEN}$i installed correctly${NC}\n"
35 ((correct++))
36 else
37 printf "${RED}$i FAILED${NC}\n"
38 ((failed++))
39 fi
40 fi
41done
42
43printf "installed: $installed, ${GREEN}correct: $correct${NC}, ${RED}failed: $failed${NC}\n"
44
45if [ $failed -eq 0 ]
46then
47 exit 0
48else
49 exit 1
50fi
diff --git a/tests/readme.md b/tests/readme.md
0new file mode 10064451new file mode 100644
index 0000000..50bcad8
--- /dev/null
+++ b/tests/readme.md
@@ -0,0 +1,6 @@
1The acceptance test runs several python scripts that simply import some uninstalled libraries.
2The 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.
3
4Note that the tests assume that the DPCS works automatically.
5
6Test_api is a temporary file that perhaps will be used to create complete unit tests of API.
diff --git a/tests/test_api.py b/tests/test_api.py
0new file mode 1006447new file mode 100644
index 0000000..455778d
--- /dev/null
+++ b/tests/test_api.py
@@ -0,0 +1,31 @@
1import requests, json, collections
2
3# api adress
4api_url = "http://private-a6e53-dpcs.apiary-mock.com"
5
6
7class MyClient:
8 service_url = api_url
9 def do_get(self, suffix):
10 return requests.get(self.service_url + suffix).json()
11
12
13client = MyClient()
14# print(client.do_get("/vd1/crash-reports/1"))
15service_url = api_url
16
17def do_get(self, suffix):
18 return requests.get(self.service_url + suffix).json()
19
20data = {}
21data['crash-reports'] = 'vd1/crash-reports/'
22data['crash-groups'] = 'vd1/crash-groups/'
23data['solutions'] = 'vd1/solutions/'
24json_test = json.dumps(data)
25
26client = MyClient()
27json_from_api = client.do_get("/vd1/paths/")
28
29json_test_object = json.loads(json_test)
30
31assert json_test_object == json_from_api

Subscribers

People subscribed via source and target branches

to all changes: