Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simple tests #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions tests/acceptance_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

declare -a arr PACK=(
"prettytable"
"delorean"
"snowballstemmer"
"wget"
"sh"
"fuzzywuzzy"
"progressbar"
"uuid"
"bashplotlib"
)

echo Start tests
installed=0
failed=0
correct=0

RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

for i in "${PACK[@]}"
do
echo "Check: $i"
python -c "import $i" &> /dev/null
if [ $? -eq 0 ]; then
echo "$i already installed"
((installed++))
else
python -c "import $i" &> /dev/null
if [ $? -eq 0 ]; then
printf "${GREEN}$i installed correctly${NC}\n"
((correct++))
else
printf "${RED}$i FAILED${NC}\n"
((failed++))
fi
fi
done

printf "installed: $installed, ${GREEN}correct: $correct${NC}, ${RED}failed: $failed${NC}\n"

if [ $failed -eq 0 ]
then
exit 0
else
exit 1
fi
6 changes: 6 additions & 0 deletions tests/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The acceptance test runs several python scripts that simply import some uninstalled libraries.
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.

Note that the tests assume that the DPCS works automatically.

Test_api is a temporary file that perhaps will be used to create complete unit tests of the API.
31 changes: 31 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import requests, json, collections

# api adress
api_url = "http://private-a6e53-dpcs.apiary-mock.com"


class MyClient:
service_url = api_url
def do_get(self, suffix):
return requests.get(self.service_url + suffix).json()


client = MyClient()
# print(client.do_get("/vd1/crash-reports/1"))
service_url = api_url

def do_get(self, suffix):
return requests.get(self.service_url + suffix).json()

data = {}
data['crash-reports'] = 'vd1/crash-reports/'
data['crash-groups'] = 'vd1/crash-groups/'
data['solutions'] = 'vd1/solutions/'
json_test = json.dumps(data)

client = MyClient()
json_from_api = client.do_get("/vd1/paths/")

json_test_object = json.loads(json_test)

assert json_test_object == json_from_api
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this test be written using a test framework? We'll probaby use pytest, so I'd recommend this one.