Skip to content

Commit

Permalink
Add test case for getting a Spark app by ID in test_spark_app_service.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwenyihust committed Aug 19, 2024
1 parent fc57670 commit 339bb01
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/tests/services/test_spark_app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ def tearDown(self):
db.session.remove()
db.drop_all()

def test_get_spark_by_id(self):
with self.app.app_context():
# Create User
user_0 = UserModel(name='testuser0', eemail='[email protected]')
password = 'test_password'
user_0.set_password(password)
db.session.add(user_0)
db.session.commit()
g.user = user_0

# Create notebook
notebook_0 = NotebookModel(name='Test Notebook', path='/path/to/notebook', user_id=user_0.id)
db.session.add(notebook_0)
db.session.commit()

# Create spark app
spark_app_0 = SparkAppModel(spark_app_id='1234', notebook_id=notebook_0.id, user_id=user_0.id)
db.session.add(spark_app_0)

# Get spark app by id
spark_app_1 = SparkApp.get_spark_app_by_id(spark_app_id='1234')
self.assertEqual(spark_app_1.spark_app_id, '1234')

def test_create_spark_app(self):
with self.app.app_context():
user_0 = UserModel(name='testuser0', email='[email protected]')
Expand All @@ -46,3 +69,4 @@ def test_create_spark_app(self):
spark_app = SparkAppModel.query.filter_by(spark_app_id='1234').first()
self.assertIsNotNone(spark_app)


0 comments on commit 339bb01

Please sign in to comment.