Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Millon15 committed Jan 17, 2019
1 parent 61ee632 commit d15f79f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 27 deletions.
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
# Hello cheatera!
### **Some of us use checkers time to time, some of us haven't used it before, but today everything will change! Introducing pyChecker for php_piscine!!!**
### **Some of us use checkers time to time, some of us haven't used it before, but today everything will change! Introducing Checker for php_piscine!!!**

So you can ask me: `How can we use these gorgeous unit-tests?` I can easily answer: `You just need to...`

### 1. Open unit-test folder

### 2. Watch out for an appropriate test for you

For example you need to test day01 of your piscine: `test_d01.py` fits perfectly

### 3. Then you need to configure this test for your purposes
For example your `d01` folder lies this way:

├── d01
└── unit-tests
So you need to edit head of `test_d01.py` the next way:
```python
#!/usr/bin/python
Go to `unit-tests` folder and run the `configurator.sh` script with one argument:

Usage:

./configurator.sh <Path_to_your_php_piscine_folder>

from helper import *
Example:

day_location = "../d01/"
helpers = "helpers_d01/"
./configurator.sh /Users/vbrazas/projects/archive/php_piscine/
~OR~
./configurator.sh ../

# START OF TESTS START OF TESTS START OF TESTS START OF TESTS
```
### Congrats! Now unit-test is finally configured and you can easily run it:
```bash
./test_d01.py
```
Now you can easely use all tests!
21 changes: 21 additions & 0 deletions unit-tests/configurator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#/bin/zsh

if [[ ! "$1" ]]; then
echo "Usage: ./configurator.sh <Path_to_your_php_piscine_folder>"
exit 1
fi

PWD=$(pwd)
PP=$(cd $1; pwd)

for i in {1..7}; do
k='py'
if (( i == 5 )); then continue; fi
if (( i == 6 )); then k='sh'; fi
sed -i '' -e "s|day_location = .*|day_location = '$PP/d0$i/'|" test_d0${i}.$k
sed -i '' -e "s|helpers = .*|helpers = '$PWD/helpers_d0$i/'|" test_d0${i}.$k
done

printf "Paths successfully updated to:\n"
echo "Piscine path: $PP"
echo "Helpers path: $PWD"
22 changes: 16 additions & 6 deletions unit-tests/test_d01.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from helper import *

day_location = "/Users/vbrazas/projects/archive/php_piscine/d01/"
helpers = "/Users/vbrazas/projects/archive/php_piscine/unit-tests/helpers_d01/"
day_location = '/Users/vbrazas/projects/archive/php_piscine/d01/'
helpers = '/Users/vbrazas/projects/archive/php_piscine/unit-tests/helpers_d01/'

# START OF TESTS START OF TESTS START OF TESTS START OF TESTS

Expand Down Expand Up @@ -124,7 +124,8 @@
print("")

test_command('php ' + day_location + 'ex09/ssap2.php', "")
test_command('php ' + day_location + 'ex09/ssap2.php toto tutu 4234 "_hop XXX" "##" "1948372 AhAhAh"', """AhAhAh
test_command('php ' + day_location + 'ex09/ssap2.php toto tutu 4234 "_hop XXX" "##" "1948372 AhAhAh"'
, """AhAhAh
toto
tutu
XXX
Expand All @@ -133,18 +134,27 @@
##
_hop
""")
test_command('php ' + day_location + 'ex09/ssap2.php abcd# abcd1 abcdA abcda'
, """abcdA
abcda
abcd1
abcd#
""")
test_command('php ' + day_location + 'ex09/ssap2.php aaa aaaa', """aaa
aaaa
""")
test_command('php ' + day_location + 'ex09/ssap2.php "aaa aaaa"', """aaa
aaaa
""")
test_command('php ' + day_location + 'ex09/ssap2.php "hello "', """hello
test_command('php ' + day_location + 'ex09/ssap2.php "hello "'
, """hello
""")
test_command('php ' + day_location + 'ex09/ssap2.php "aaaa aaa"', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php "aaaa aaa"'
, """aaa
aaaa
""")
test_command('php ' + day_location + 'ex09/ssap2.php aaaa aaa', """aaa
test_command('php ' + day_location + 'ex09/ssap2.php aaaa aaa'
, """aaa
aaaa
""")
# TODO: someone some tests here to test the ord thingy
Expand Down
4 changes: 2 additions & 2 deletions unit-tests/test_d02.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from helper import *

day_location = "/Users/vbrazas/projects/archive/php_piscine/d02/"
helpers = "/Users/vbrazas/projects/archive/php_piscine/unit-tests/resources_d02/"
day_location = '/Users/vbrazas/projects/archive/php_piscine/d02/'
helpers = '/Users/vbrazas/projects/archive/php_piscine/unit-tests/helpers_d02/'

# START OF TESTS START OF TESTS START OF TESTS START OF TESTS

Expand Down
4 changes: 2 additions & 2 deletions unit-tests/test_d03.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# from os.path import isfile
# from os.path import isdir

day_location = "http://localhost:8100/deleteme"
# day_location = "http://localhost:8100/php_piscine/d03"
day_location = '/Users/vbrazas/projects/archive/php_piscine/d03/'
# day_location = '/Users/vbrazas/projects/archive/php_piscine/d03/'

# START OF TESTS START OF TESTS START OF TESTS START OF TESTS

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion unit-tests/test_d07.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# expanduser, isfile, isdir, chdir
import os

day_location = "/Users/vbrazas/.Trash/vbrazas2/"
day_location = '/Users/vbrazas/projects/archive/php_piscine/d07/'
resources = "/Users/vbrazas/projects/php_piscine/unit-tests/resources_d07/"
tester_dir = os.getcwd()

Expand Down

0 comments on commit d15f79f

Please sign in to comment.