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

Commit

Permalink
Fix: set defaults for SparkConfiguration, add tests (#606)
Browse files Browse the repository at this point in the history
* add SparkConfiguration tests

* change test directory structure
  • Loading branch information
jafreck authored Jun 15, 2018
1 parent 34b2585 commit 5306a2a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:

script:
- pylint -E aztk
- pytest --ignore=tests/spark/integration_tests
- pytest --ignore=tests/integration_tests

branches:
only:
Expand Down
6 changes: 3 additions & 3 deletions aztk/spark/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class File(aztk.models.File):


class SparkConfiguration(Model):
spark_defaults_conf = fields.String()
spark_env_sh = fields.String()
core_site_xml = fields.String()
spark_defaults_conf = fields.String(default=None)
spark_env_sh = fields.String(default=None)
core_site_xml = fields.String(default=None)
jars = fields.List()

def __init__(self, *args, **kwargs):
Expand Down
23 changes: 23 additions & 0 deletions tests/spark/models/test_spark_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from aztk.spark.models import SparkConfiguration
from aztk.error import InvalidModelError


def test_spark_configuration_defaults():
spark_configuration = SparkConfiguration()
spark_configuration.validate()

assert spark_configuration.spark_defaults_conf is None
assert spark_configuration.spark_defaults_conf is None
assert spark_configuration.spark_defaults_conf is None

def test_spark_configuration_fields():
spark_configuration = SparkConfiguration(
spark_defaults_conf="spark-defaults.conf",
spark_env_sh="spark-env.sh",
core_site_xml="core-site.xml",
)
spark_configuration.validate()

assert spark_configuration.spark_defaults_conf == "spark-defaults.conf"
assert spark_configuration.spark_env_sh == "spark-env.sh"
assert spark_configuration.core_site_xml == "core-site.xml"

0 comments on commit 5306a2a

Please sign in to comment.