-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.databricks/ | ||
.venv/ | ||
.pytest_cache/ | ||
*.pyc | ||
__pycache__/ | ||
.pytest_cache/ | ||
dist/ | ||
build/ | ||
covid_analysis.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "databricks", | ||
"request": "launch", | ||
"name": "Unit Tests (on Databricks)", | ||
"program": "${workspaceFolder}/jobs/pytest_databricks.py", | ||
"args": ["./tests"], | ||
"env": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
import os | ||
import sys | ||
|
||
# Run all tests in the repository root. | ||
repo_root = os.path.dirname(os.getcwd()) | ||
os.chdir(repo_root) | ||
|
||
# Skip writing pyc files on a readonly filesystem. | ||
sys.dont_write_bytecode = True | ||
|
||
_ = pytest.main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from pyspark.sql import SparkSession | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def spark() -> SparkSession: | ||
""" | ||
Create a spark session. Unit tests don't have access to the spark global | ||
""" | ||
return SparkSession.builder.getOrCreate() | ||
|
||
|
||
def test_spark(spark): | ||
""" | ||
Example test that needs to run on the cluster to work | ||
""" | ||
data = spark.sql("select 1").collect() | ||
assert data[0][0] == 1 |