-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
a57e32a
commit a65e1ab
Showing
6 changed files
with
65 additions
and
43 deletions.
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,38 +1,37 @@ | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from growth_forge.models import Profile | ||
from django.test import TestCase | ||
from projects.models import Project | ||
|
||
from growth_forge.models import Profile | ||
|
||
User = get_user_model() | ||
|
||
|
||
class ProfileTests(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
# Create a user for testing | ||
cls.user = User.objects.create_user( | ||
# username='testuser2', | ||
password='testpassword2', | ||
email='[email protected]' | ||
# username='testuser2', | ||
password='testpassword2', | ||
email='[email protected]', | ||
) | ||
cls.user2 = User.objects.create_user( | ||
email='[email protected]', password='testpassword' | ||
) | ||
cls.user2 = User.objects.create_user(email='[email protected]', password='testpassword') | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
# Create a user for testing | ||
cls.user.delete() | ||
cls.user.delete() | ||
|
||
cls.user2.delete() | ||
cls.user2.delete() | ||
|
||
def test_create_profile(self): | ||
# The Profile should be created automatically due to the post_save signal | ||
profile = Profile.objects.get(user=self.user) | ||
self.assertIsNotNone( | ||
profile | ||
) | ||
self.assertEqual( | ||
profile.user.email, | ||
'[email protected]' | ||
) | ||
self.assertIsNotNone(profile) | ||
self.assertEqual(profile.user.email, '[email protected]') | ||
|
||
def test_retrieve_profile(self): | ||
profile = Profile.objects.get(user=self.user) | ||
|
@@ -46,7 +45,6 @@ def test_update_profile(self): | |
profile.projects.add(project) | ||
# Verify the profile has the project added | ||
self.assertIn(project, profile.projects.all()) | ||
|
||
|
||
def test_delete_profile(self): | ||
profile = Profile.objects.get(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from tests import * | ||
from tests import * |
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,26 +1,28 @@ | ||
#test models code yet to be inserted | ||
#test models code yet to be inserted | ||
from django.test import TestCase | ||
# test models code yet to be inserted | ||
# test models code yet to be inserted | ||
from datetime import timedelta | ||
|
||
from django.contrib.auth import get_user_model | ||
from growth_plan.models import GrowthPlanItem | ||
from django.test import TestCase | ||
from django.utils import timezone | ||
from datetime import timedelta | ||
|
||
from growth_plan.models import GrowthPlanItem | ||
|
||
User = get_user_model() | ||
|
||
class GrowthPlanItemTests(TestCase): | ||
|
||
class GrowthPlanItemTests(TestCase): | ||
def setUp(self): | ||
# Create a user for testing | ||
self.user = User.objects.create_user( | ||
# username='testuser', | ||
password='testpassword', | ||
email='[email protected]' | ||
email='[email protected]', | ||
) | ||
self.client.login( | ||
# username='testuser', | ||
# username='testuser', | ||
password='testpassword', | ||
email='[email protected]' | ||
email='[email protected]', | ||
) | ||
|
||
# Common data for test cases | ||
|
@@ -34,24 +36,32 @@ def setUp(self): | |
} | ||
|
||
def test_create_growth_plan_item(self): | ||
growth_plan_item = GrowthPlanItem.objects.create(**self.growth_plan_item_data) | ||
growth_plan_item = GrowthPlanItem.objects.create( | ||
**self.growth_plan_item_data | ||
) | ||
self.assertEqual(GrowthPlanItem.objects.count(), 1) | ||
self.assertEqual(growth_plan_item.title, 'Test Growth Plan') | ||
|
||
def test_retrieve_growth_plan_item(self): | ||
growth_plan_item = GrowthPlanItem.objects.create(**self.growth_plan_item_data) | ||
growth_plan_item = GrowthPlanItem.objects.create( | ||
**self.growth_plan_item_data | ||
) | ||
retrieved_item = GrowthPlanItem.objects.get(id=growth_plan_item.id) | ||
self.assertEqual(retrieved_item.title, growth_plan_item.title) | ||
|
||
def test_update_growth_plan_item(self): | ||
growth_plan_item = GrowthPlanItem.objects.create(**self.growth_plan_item_data) | ||
growth_plan_item = GrowthPlanItem.objects.create( | ||
**self.growth_plan_item_data | ||
) | ||
growth_plan_item.title = 'Updated Title' | ||
growth_plan_item.save() | ||
updated_item = GrowthPlanItem.objects.get(id=growth_plan_item.id) | ||
self.assertEqual(updated_item.title, 'Updated Title') | ||
|
||
def test_delete_growth_plan_item(self): | ||
growth_plan_item = GrowthPlanItem.objects.create(**self.growth_plan_item_data) | ||
growth_plan_item = GrowthPlanItem.objects.create( | ||
**self.growth_plan_item_data | ||
) | ||
growth_plan_item_id = growth_plan_item.id | ||
growth_plan_item.delete() | ||
with self.assertRaises(GrowthPlanItem.DoesNotExist): | ||
|
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,17 +1,22 @@ | ||
#test models code yet to be inserted | ||
from django.test import TestCase | ||
# test models code yet to be inserted | ||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
from djf_surveys.models import Survey | ||
|
||
from one_on_one.models import Link | ||
|
||
User = get_user_model() | ||
|
||
class LinkTests(TestCase): | ||
|
||
class LinkTests(TestCase): | ||
def setUp(self): | ||
# Create users for testing | ||
self.mentor = User.objects.create_user(email='[email protected]', password='testpassword') | ||
self.mentee = User.objects.create_user(email='[email protected]', password='testpassword') | ||
self.mentor = User.objects.create_user( | ||
email='[email protected]', password='testpassword' | ||
) | ||
self.mentee = User.objects.create_user( | ||
email='[email protected]', password='testpassword' | ||
) | ||
|
||
# Create surveys for testing | ||
self.mentor_survey = Survey.objects.create(name='Mentor Survey') | ||
|
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,15 +1,20 @@ | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
|
||
from projects.models import Project | ||
|
||
User = get_user_model() | ||
|
||
class ProjectTests(TestCase): | ||
|
||
class ProjectTests(TestCase): | ||
def setUp(self): | ||
# Create users for testing | ||
self.user1 = User.objects.create_user(email='[email protected]', password='testpassword') | ||
self.user2 = User.objects.create_user(email='[email protected]', password='testpassword') | ||
self.user1 = User.objects.create_user( | ||
email='[email protected]', password='testpassword' | ||
) | ||
self.user2 = User.objects.create_user( | ||
email='[email protected]', password='testpassword' | ||
) | ||
|
||
# Common data for test cases | ||
self.project_data = { | ||
|
@@ -49,4 +54,4 @@ def test_delete_project(self): | |
project_id = project.id | ||
project.delete() | ||
with self.assertRaises(Project.DoesNotExist): | ||
Project.objects.get(id=project_id) | ||
Project.objects.get(id=project_id) |