-
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
d564098
commit a57e32a
Showing
9 changed files
with
228 additions
and
10 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 +1,56 @@ | ||
#test models code yet to be inserted | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from growth_forge.models import Profile | ||
from projects.models import Project | ||
|
||
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]' | ||
) | ||
cls.user2 = User.objects.create_user(email='[email protected]', password='testpassword') | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
# Create a user for testing | ||
cls.user.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]' | ||
) | ||
|
||
def test_retrieve_profile(self): | ||
profile = Profile.objects.get(user=self.user) | ||
retrieved_profile = Profile.objects.get(id=profile.id) | ||
self.assertEqual(retrieved_profile.user.email, '[email protected]') | ||
|
||
def test_update_profile(self): | ||
profile, _ = Profile.objects.get_or_create(user=self.user) | ||
# Create a Project instance and add it to the profile's projects | ||
project = Project.objects.create(name='Test Project') | ||
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) | ||
profile_id = profile.id | ||
profile.delete() | ||
with self.assertRaises(Profile.DoesNotExist): | ||
Profile.objects.get(id=profile_id) |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
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 +1,58 @@ | ||
#test models code yet to be inserted | ||
#test models code yet to be inserted | ||
#test models code yet to be inserted | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from growth_plan.models import GrowthPlanItem | ||
from django.utils import timezone | ||
from datetime import timedelta | ||
|
||
User = get_user_model() | ||
|
||
class GrowthPlanItemTests(TestCase): | ||
|
||
def setUp(self): | ||
# Create a user for testing | ||
self.user = User.objects.create_user( | ||
# username='testuser', | ||
password='testpassword', | ||
email='[email protected]' | ||
) | ||
self.client.login( | ||
# username='testuser', | ||
password='testpassword', | ||
email='[email protected]' | ||
) | ||
|
||
# Common data for test cases | ||
self.growth_plan_item_data = { | ||
'user': self.user, | ||
'title': 'Test Growth Plan', | ||
'description': 'This is a test description.', | ||
'start_date': timezone.now().date(), | ||
'end_date': (timezone.now() + timedelta(days=10)).date(), | ||
'progress_percentage': 50, | ||
} | ||
|
||
def test_create_growth_plan_item(self): | ||
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) | ||
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.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_id = growth_plan_item.id | ||
growth_plan_item.delete() | ||
with self.assertRaises(GrowthPlanItem.DoesNotExist): | ||
GrowthPlanItem.objects.get(id=growth_plan_item_id) |
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
#test models code yet to be inserted | ||
#test models code yet to be inserted | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from djf_surveys.models import Survey | ||
from one_on_one.models import Link | ||
|
||
User = get_user_model() | ||
|
||
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') | ||
|
||
# Create surveys for testing | ||
self.mentor_survey = Survey.objects.create(name='Mentor Survey') | ||
self.mentee_survey = Survey.objects.create(name='Mentee Survey') | ||
|
||
# Common data for test cases | ||
self.link_data = { | ||
'mentor': self.mentor, | ||
'mentee': self.mentee, | ||
'mentor_survey': self.mentor_survey, | ||
'mentee_survey': self.mentee_survey, | ||
'periodicity': 'weekly', | ||
'times': 5, | ||
} | ||
|
||
def test_create_link(self): | ||
link = Link.objects.create(**self.link_data) | ||
self.assertEqual(Link.objects.count(), 1) | ||
self.assertEqual(link.mentor.email, '[email protected]') | ||
self.assertEqual(link.mentee.email, '[email protected]') | ||
self.assertEqual(link.periodicity, 'weekly') | ||
|
||
def test_retrieve_link(self): | ||
link = Link.objects.create(**self.link_data) | ||
retrieved_link = Link.objects.get(id=link.id) | ||
self.assertEqual(retrieved_link.mentor.email, '[email protected]') | ||
self.assertEqual(retrieved_link.mentee.email, '[email protected]') | ||
|
||
def test_update_link(self): | ||
link = Link.objects.create(**self.link_data) | ||
link.periodicity = 'monthly' | ||
link.times = 10 | ||
link.save() | ||
updated_link = Link.objects.get(id=link.id) | ||
self.assertEqual(updated_link.periodicity, 'monthly') | ||
self.assertEqual(updated_link.times, 10) | ||
|
||
def test_delete_link(self): | ||
link = Link.objects.create(**self.link_data) | ||
link_id = link.id | ||
link.delete() | ||
with self.assertRaises(Link.DoesNotExist): | ||
Link.objects.get(id=link_id) |
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
from projects.models import Project | ||
|
||
User = get_user_model() | ||
|
||
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') | ||
|
||
# Common data for test cases | ||
self.project_data = { | ||
'name': 'Test Project', | ||
} | ||
|
||
def test_create_project(self): | ||
project = Project.objects.create(**self.project_data) | ||
project.observers.add(self.user1, self.user2) | ||
self.assertEqual(Project.objects.count(), 1) | ||
self.assertEqual(project.name, 'Test Project') | ||
self.assertIn(self.user1, project.observers.all()) | ||
self.assertIn(self.user2, project.observers.all()) | ||
|
||
def test_retrieve_project(self): | ||
project = Project.objects.create(**self.project_data) | ||
project.observers.add(self.user1, self.user2) | ||
retrieved_project = Project.objects.get(id=project.id) | ||
self.assertEqual(retrieved_project.name, 'Test Project') | ||
self.assertIn(self.user1, retrieved_project.observers.all()) | ||
self.assertIn(self.user2, retrieved_project.observers.all()) | ||
|
||
def test_update_project(self): | ||
project = Project.objects.create(**self.project_data) | ||
project.observers.add(self.user1) | ||
project.name = 'Updated Project' | ||
project.observers.remove(self.user1) | ||
project.observers.add(self.user2) | ||
project.save() | ||
updated_project = Project.objects.get(id=project.id) | ||
self.assertEqual(updated_project.name, 'Updated Project') | ||
self.assertNotIn(self.user1, updated_project.observers.all()) | ||
self.assertIn(self.user2, updated_project.observers.all()) | ||
|
||
def test_delete_project(self): | ||
project = Project.objects.create(**self.project_data) | ||
project_id = project.id | ||
project.delete() | ||
with self.assertRaises(Project.DoesNotExist): | ||
Project.objects.get(id=project_id) |