-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing unit testing of create app instances from view form
- Loading branch information
Showing
2 changed files
with
44 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,12 +1,15 @@ | ||
"""This module is used to test the helper functions that are used by user app instance functionality.""" | ||
|
||
import unittest | ||
from unittest.mock import patch | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
|
||
from projects.models import Project | ||
from projects.models import Flavor, Project | ||
|
||
from ..app_registry import APP_REGISTRY | ||
from ..helpers import create_instance_from_form | ||
from ..models import Apps, JupyterInstance, K8sUserAppStatus | ||
|
||
User = get_user_model() | ||
|
@@ -17,13 +20,43 @@ class CreateAppInstanceTestCase(TestCase): | |
|
||
def setUp(self): | ||
self.user = User.objects.create_user("foo1", "[email protected]", "bar") | ||
self.project = Project.objects.create_project(name="test-app-creation", owner=self.user, description="") | ||
|
||
@unittest.expectedFailure | ||
def test_create_instance_from_form_valid_input(self): | ||
# TODO: Status | ||
|
||
# Create the form data | ||
flavor = Flavor.objects.filter(project=self.project).first() | ||
|
||
app_slug = "dashapp" | ||
|
||
data = { | ||
"name": "app-form-name", | ||
"description": "app-form-description", | ||
"flavor": str(flavor.pk), | ||
"access": "public", | ||
"port": 8000, | ||
"image": "some-image", | ||
"source_code_url": "https://someurlthatdoesnotexist.com", | ||
} | ||
|
||
_, form_class = APP_REGISTRY.get(app_slug) | ||
form = form_class(data, project_pk=self.project.pk) | ||
|
||
with patch("apps.tasks.delete_resource.delay") as mock_task: # noqa: F841 | ||
create_instance_from_form(form, self.project, app_slug, app_id=None) | ||
|
||
pass | ||
|
||
self.assertTrue(1 == 0) | ||
|
||
@unittest.expectedFailure | ||
def test_create_instance_from_form_invalid_input(self): | ||
# TODO: Status | ||
with patch("apps.tasks.delete_resource.delay") as mock_task: # noqa: F841 | ||
pass | ||
|
||
self.assertTrue(1 == 0) | ||
|
||
|
||
|
@@ -49,10 +82,18 @@ def setUp(self) -> None: | |
k8s_user_app_status=k8s_user_app_status, | ||
) | ||
|
||
@unittest.expectedFailure | ||
def test_create_instance_from_form_valid_input(self): | ||
# TODO: Status. Implement | ||
with patch("apps.tasks.delete_resource.delay") as mock_task: # noqa: F841 | ||
pass | ||
|
||
self.assertTrue(1 == 0) | ||
|
||
@unittest.expectedFailure | ||
def test_create_instance_from_form_invalid_input(self): | ||
# TODO: Status. Implement | ||
with patch("apps.tasks.delete_resource.delay") as mock_task: # noqa: F841 | ||
pass | ||
|
||
self.assertTrue(1 == 0) |
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