Skip to content

Commit 734a693

Browse files
authored
Merge pull request #59 from invertase/test-lab
feat: test lab function support
2 parents ceea2f0 + 42b4d3a commit 734a693

File tree

9 files changed

+516
-0
lines changed

9 files changed

+516
-0
lines changed

samples/basic_test_lab/.firebaserc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "python-functions-testing"
4+
}
5+
}

samples/basic_test_lab/.gitignore

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
firebase-debug.log*
8+
firebase-debug.*.log*
9+
10+
# Firebase cache
11+
.firebase/
12+
13+
# Firebase config
14+
15+
# Uncomment this if you'd like others to create their own Firebase project.
16+
# For a team working on the same Firebase project(s), it is recommended to leave
17+
# it commented so all members can deploy to the same project(s) in .firebaserc.
18+
# .firebaserc
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36+
.grunt
37+
38+
# Bower dependency directory (https://bower.io/)
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons (http://nodejs.org/api/addons.html)
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional REPL history
57+
.node_repl_history
58+
59+
# Output of 'npm pack'
60+
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env

samples/basic_test_lab/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Required to avoid a 'duplicate modules' mypy error
2+
# in monorepos that have multiple main.py files.
3+
# https://github.com/python/mypy/issues/4008

samples/basic_test_lab/firebase.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"functions": [
3+
{
4+
"source": "functions",
5+
"codebase": "default",
6+
"ignore": [
7+
"venv"
8+
]
9+
}
10+
]
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# pyenv
2+
.python-version
3+
4+
# Installer logs
5+
pip-log.txt
6+
pip-delete-this-directory.txt
7+
8+
# Environments
9+
.env
10+
.venv
11+
venv/
12+
venv.bak/
13+
__pycache__
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Firebase Cloud Functions for Test Lab."""
2+
from firebase_functions.test_lab_fn import (
3+
CloudEvent,
4+
TestMatrixCompletedData,
5+
on_test_matrix_completed,
6+
)
7+
8+
9+
@on_test_matrix_completed()
10+
def testmatrixcompleted(event: CloudEvent[TestMatrixCompletedData]) -> None:
11+
print(f"Test Matrix ID: {event.data.test_matrix_id}")
12+
print(f"Test Matrix State: {event.data.state}")
13+
print(f"Test Matrix Outcome Summary: {event.data.outcome_summary}")
14+
15+
print("Result Storage:")
16+
print(
17+
f" Tool Results History: {event.data.result_storage.tool_results_history}"
18+
)
19+
print(f" Results URI: {event.data.result_storage.results_uri}")
20+
print(f" GCS Path: {event.data.result_storage.gcs_path}")
21+
print(
22+
f" Tool Results Execution: {event.data.result_storage.tool_results_execution}"
23+
)
24+
25+
print("Client Info:")
26+
print(f" Client: {event.data.client_info.client}")
27+
print(f" Details: {event.data.client_info.details}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Not published yet,
2+
# firebase-functions-python >= 0.0.1
3+
# so we use a relative path during development:
4+
./../../../
5+
# Or switch to git ref for deployment testing:
6+
# git+https://github.com/firebase/firebase-functions-python.git@main#egg=firebase-functions
7+
8+
firebase-admin >= 6.0.1

0 commit comments

Comments
 (0)