1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!/bin/sh
test_dir=$(cd $(dirname $0) && pwd)
source "$test_dir/setup.sh"
oneTimeSetUp() {
rm -rf "$WORKON_HOME"
mkdir -p "$WORKON_HOME"
source "$test_dir/../virtualenvwrapper.sh"
}
oneTimeTearDown() {
rm -rf "$WORKON_HOME"
rm -f "$test_dir/requirements.txt"
}
setUp () {
echo
rm -f "$test_dir/catch_output"
echo "#!/bin/sh" > "$WORKON_HOME/preactivate"
echo "#!/bin/sh" > "$WORKON_HOME/postactivate"
}
test_associate() {
project="/dev/null"
env="env1"
ptrfile="$WORKON_HOME/$env/.project"
mkvirtualenv -a "$project" "$env" >/dev/null 2>&1
assertTrue ".project not found" "[ -f $ptrfile ]"
assertEquals "$ptrfile contains wrong content" "$project" "$(cat $ptrfile)"
}
test_preactivate() {
project="/dev/null"
env="env2"
ptrfile="$WORKON_HOME/$env/.project"
cat - >"$WORKON_HOME/preactivate" <<EOF
#!/bin/sh
if [ -f "$ptrfile" ]
then
echo exists >> "$test_dir/catch_output"
else
echo noexists >> "$test_dir/catch_output"
fi
EOF
chmod +x "$WORKON_HOME/preactivate"
mkvirtualenv -a "$project" "$env" >/dev/null 2>&1
assertSame "preactivate did not find file" "exists" "$(cat $test_dir/catch_output)"
}
test_postactivate() {
project="/dev/null"
env="env3"
ptrfile="$WORKON_HOME/$env/.project"
cat - >"$WORKON_HOME/postactivate" <<EOF
#!/bin/sh
if [ -f "$ptrfile" ]
then
echo exists >> "$test_dir/catch_output"
else
echo noexists >> "$test_dir/catch_output"
fi
EOF
chmod +x "$WORKON_HOME/postactivate"
mkvirtualenv -a "$project" "$env" >/dev/null 2>&1
assertSame "postactivate did not find file" "exists" "$(cat $test_dir/catch_output)"
}
. "$test_dir/shunit2"
|