Skip to content

Commit 11c06eb

Browse files
authored
fix virtualenv tests (ibm-functions#15)
* fix virtualenv tests
1 parent e43b7fe commit 11c06eb

6 files changed

Lines changed: 34 additions & 23 deletions

File tree

python3/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ RUN apt-get update && apt-get install -y \
99
libxml2-dev \
1010
libffi-dev \
1111
libssl-dev \
12+
zip \
1213
unzip \
14+
vim \
1315
&& rm -rf /var/lib/apt/lists/*
1416

1517
RUN apt-cache search linux-headers-generic

python3/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ virtualenv == 15.1.0
1717
twisted == 17.1.0
1818

1919
# IBM specific python modules
20-
ibm_db == 2.0.7
20+
ibm_db == 2.0.8a
2121
cloudant == 2.7.0
2222
watson-developer-cloud == 1.0.2
2323
ibm-cos-sdk == 2.0.0

tests/dat/actions/p3zip/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ def main(args):
1212
def naim(args):
1313
return main(args)
1414

15+
if __name__ == "__main__":
16+
# execute only if run as a script
17+
print(main({}))
18+

tests/dat/actions/p3zip/build.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!/bin/bash
22

3-
rm ../python3_jessie_virtualenv.zip
3+
#helper file to create and test python zip action
4+
5+
ZIP_NAME="python3_jessie_virtualenv.zip"
6+
IMAGE_NAME="ibmfunctions/action-python-v3:latest"
7+
ACTION_NAME="zip_jessie"
8+
9+
rm ${ZIP_NAME}
410
rm -r virtualenv
5-
docker run --rm -v "$PWD:/tmp" action-python-v3 sh -c "cd tmp; virtualenv virtualenv; source virtualenv/bin/activate; pip install -r requirements.txt;"
6-
zip -r ../python3_jessie_virtualenv.zip virtualenv __main__.py
11+
set -ex
712

13+
docker run --rm -v "$PWD:/tmp" ${IMAGE_NAME} bash -c "cd /tmp && virtualenv virtualenv && source virtualenv/bin/activate && pip install -r requirements.txt"
14+
zip -r ${ZIP_NAME} virtualenv __main__.py
15+
bx wsk action update ${ACTION_NAME} ${ZIP_NAME} --docker ${IMAGE_NAME}
16+
bx wsk action invoke ${ACTION_NAME} -b
3.61 MB
Binary file not shown.

tests/src/test/scala/system/basic/WskBasicIBMPythonTests.scala

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package system.basic
1919
import org.junit.runner.RunWith
2020
import org.scalatest.junit.JUnitRunner
2121
import org.scalatest.Matchers
22-
//import scala.concurrent.duration.DurationInt
22+
import scala.concurrent.duration.DurationInt
2323
import spray.json._
2424
import spray.json.DefaultJsonProtocol.StringJsonFormat
25-
//import java.io.File
25+
import java.io.File
2626
import common.JsHelpers
2727
import common.TestHelpers
2828
import common.TestUtils
@@ -113,27 +113,23 @@ class WskBasicIBMPythonTests extends TestHelpers with WskTestHelpers with Matche
113113
}
114114
}
115115

116-
/*
117-
FIXME: virtualenv not working currently
118116
behavior of "Python virtualenv"
119117

120-
it should s"invoke a zipped $kind action with virtualenv package" in withAssetCleaner(wskprops) {
121-
(wp, assetHelper) =>
122-
val userdir = System.getProperty("user.dir") + "/dat/actions/"
123-
val filename = "python3_jessie_virtualenv.zip"
124-
val name = filename
125-
val zippedPythonAction = Some(new File(userdir, filename).toString())
118+
it should s"invoke a zipped $kind action with virtualenv package" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
119+
val userdir = System.getProperty("user.dir") + "/dat/actions/p3zip"
120+
val filename = "python3_jessie_virtualenv.zip"
121+
val name = filename
122+
val zippedPythonAction = Some(new File(userdir, filename).toString())
126123

127-
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
128-
action.create(name, zippedPythonAction, kind = Some(kind))
129-
}
124+
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
125+
action.create(name, zippedPythonAction, kind = Some(kind))
126+
}
130127

131-
withActivation(wsk.activation, wsk.action.invoke(name), totalWait = 120.seconds) { activation =>
132-
val response = activation.response
133-
response.result.get.fields.get("error") shouldBe empty
134-
response.result.get.fields.get("Networkinfo: ") shouldBe defined
135-
}
128+
withActivation(wsk.activation, wsk.action.invoke(name), totalWait = 120.seconds) { activation =>
129+
val response = activation.response
130+
response.result.get.fields.get("error") shouldBe empty
131+
response.result.get.fields.get("Networkinfo: ") shouldBe defined
132+
}
136133
}
137-
*/
138134

139135
}

0 commit comments

Comments
 (0)