-
Notifications
You must be signed in to change notification settings - Fork 0
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
16 changed files
with
260 additions
and
6 deletions.
There are no files selected for viewing
Empty file.
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,30 @@ | ||
from unittest import TestCase | ||
|
||
import pytest | ||
from django.conf import settings | ||
from faker import Faker | ||
from model_bakery import baker | ||
|
||
from apps.sql_data.models import SQLDatabaseSource | ||
from apps.users.models import User | ||
|
||
fake = Faker() | ||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
class AuditBaseModelTest(TestCase): | ||
"""Test for AuditBase.""" | ||
|
||
def setUp(self): | ||
self.user = baker.make(settings.AUTH_USER_MODEL, email=fake.email()) | ||
super().setUp() | ||
|
||
def test_created_and_created_by(self): | ||
sql_upload_metadata = SQLDatabaseSource( | ||
pk=None, | ||
name="name", | ||
description="myql db", | ||
database_name="sql", | ||
database_vendor="MySQL", | ||
) | ||
sql_upload_metadata.save(user=User.objects.get(pk=self.user.pk)) |
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
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,24 @@ | ||
import pytest | ||
from faker import Faker | ||
from model_bakery import baker | ||
from rest_framework.test import APITestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.dashboards.models import Dashboard, Visualization | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
fake = Faker() | ||
|
||
|
||
class InitializeTestData(LoggedInMixin, APITestCase): | ||
def setUp(self): | ||
self.dashboard = baker.make(Dashboard) | ||
self.visualization = baker.make(Visualization) | ||
super().setUp() | ||
|
||
def test_dashboard_str(self): | ||
assert str(self.dashboard) == str(self.dashboard.title) | ||
|
||
def test_visualization_str(self): | ||
assert str(self.visualization) == str(self.visualization.title) |
Empty file.
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,29 @@ | ||
import pytest | ||
from faker import Faker | ||
from rest_framework.test import APIRequestFactory, APITestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.frontend.context_processors import dashboards | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
fake = Faker() | ||
|
||
|
||
class InitializeTestData(LoggedInMixin, APITestCase): | ||
def setUp(self): | ||
self.factory = APIRequestFactory() | ||
super().setUp() | ||
|
||
def test_context_processor_dashboards_as_staff(self): | ||
request = self.factory.request() | ||
request.user = self.user | ||
response = dashboards(request) | ||
assert response.get("dashboards") != "" | ||
|
||
def test_context_processor_dashboards_as_non_staff(self): | ||
request = self.factory.request() | ||
request.user = self.user | ||
request.user.is_staff = False | ||
response = dashboards(request) | ||
assert len(response.get("dashboards")) >= 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from unittest import TestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.frontend.views import HomeView | ||
|
||
|
||
class TestViews(LoggedInMixin, TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
def test_home_view_context(self): | ||
view = HomeView() | ||
view.get_context_data() |
Empty file.
Empty file.
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,40 @@ | ||
import pytest | ||
from django.contrib.admin.sites import AdminSite | ||
from faker import Faker | ||
from model_bakery import baker | ||
from rest_framework.test import APIRequestFactory, APITestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.sql_data.admin import DataSourceVersionAdmin | ||
from apps.sql_data.models import DataSourceVersion, SQLDatabaseSource | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
fake = Faker() | ||
|
||
|
||
class InitializeTestData(LoggedInMixin, APITestCase): | ||
def setUp(self): | ||
self.factory = APIRequestFactory() | ||
self.data_source_version = baker.make(DataSourceVersion) | ||
self.sql_data_source = baker.make(SQLDatabaseSource) | ||
super().setUp() | ||
|
||
def test_audit_base_model_audit_field_set_property(self): | ||
admin = DataSourceVersionAdmin( | ||
model=DataSourceVersion, admin_site=AdminSite() | ||
) | ||
return admin.audit_details_fieldset | ||
|
||
def test_save_model(self): | ||
data_source_admin = DataSourceVersionAdmin( | ||
model=DataSourceVersion, admin_site=AdminSite() | ||
) | ||
request = self.factory.request() | ||
request.user = self.user | ||
data_source_admin.save_model( | ||
obj=self.data_source_version, | ||
request=request, | ||
form=None, | ||
change=None, | ||
) |
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
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
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,30 @@ | ||
import pytest | ||
from faker import Faker | ||
from rest_framework.test import APIRequestFactory, APITestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.users.adapters import AccountAdapter, SocialAccountAdapter | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
fake = Faker() | ||
|
||
|
||
class InitializeTestData(LoggedInMixin, APITestCase): | ||
def setUp(self): | ||
self.factory = APIRequestFactory() | ||
super().setUp() | ||
|
||
def test_account_adapter(self): | ||
request = self.factory.request() | ||
request.user = self.user | ||
response = AccountAdapter.is_open_for_signup(self, request) | ||
assert response | ||
|
||
def test_social_account_adapter(self): | ||
request = self.factory.request() | ||
request.user = self.user | ||
response = SocialAccountAdapter.is_open_for_signup( | ||
self, request, sociallogin=None | ||
) | ||
assert response |
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,19 @@ | ||
import pytest | ||
from faker import Faker | ||
from rest_framework.test import APIRequestFactory, APITestCase | ||
|
||
from apps.common.tests.test_common import LoggedInMixin | ||
from apps.users.signals import assign_basic_permissions | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
fake = Faker() | ||
|
||
|
||
class InitializeTestData(LoggedInMixin, APITestCase): | ||
def setUp(self): | ||
self.factory = APIRequestFactory() | ||
super().setUp() | ||
|
||
def test_account_adapter(self): | ||
assert assign_basic_permissions(user=self.user) != "" |
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
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