Commit 943431d3 authored by Ola Hermann Opheim's avatar Ola Hermann Opheim
Browse files

draft test and add project status check

parent 1a12540d
......@@ -58,17 +58,25 @@ class ProjectTest(unittest.TestCase):
})
# Test project_view POST route offer response
taskofferid = get_all_taskoffers(self.testTask)[0].id
self.client.login(username= 'Owner', password= 'top_secret')
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'offer_response': True,
'taskofferid': taskofferid,
'taskofferid': 0,
'status': 'a',
'feedback': 'ja',
})
# TODO: Test project_view POST route edit project
# Test project_view POST route edit project
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_project': True,
#'edit': True,
})
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_project': True,
'project_description': 'edited',
f'task{self.testTask.id}_budget': '100',
f'task{self.testTask.id}_description': 'edited',
})
# Test project_view POST route status change
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
......@@ -76,10 +84,6 @@ class ProjectTest(unittest.TestCase):
'status': 'o',
})
def test_edit_project_integration(self):
#TODO
self.assertTrue(True)
class UserTaskPermissionTest(unittest.TestCase):
def setUp(self):
self.client = Client()
......@@ -132,10 +136,9 @@ class UserTaskPermissionTest(unittest.TestCase):
'taskvalue': Project.objects.last().pk,
})
self.client.login(username= 'Owner2', password= 'top_secret')
taskofferid = get_all_taskoffers(self.testTask2)[0].id
response = self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'offer_response': True,
'taskofferid': taskofferid,
'taskofferid': 0,
'status': 'a',
'feedback': 'ja',
})
......@@ -174,11 +177,63 @@ class ProjectOfferTest(unittest.TestCase):
class EditProjectTest(unittest.TestCase):
def setUp(self):
self.client = Client()
# TODO: crate project with new project route
def test_edit_project_description(self):
#TODO get project from context in return
self.assertTrue(True)
def test_edit_project_and_tasks(self):
self.edit_project_category = ProjectCategory.objects.create(name='edit_project_category')
self.project_owner = User.objects.create_user(
username='ProjectOwner',
email='test@test.com',
password='top_secret'
)
self.edit_project_test_project = Project.objects.create(
user=self.project_owner.profile,
title='Edit project test project',
description='',
category=self.edit_project_category,
status='o'
)
self.edit_project_test_task1 = Task.objects.create(
project=self.edit_project_test_project,
title='Test task 1',
description='',
budget=20,
status='ad',
feedback=''
)
self.edit_project_test_task2 = Task.objects.create(
project=self.edit_project_test_project,
title='Test task 2',
description='',
budget=30,
status='ad',
feedback=''
)
# Test project exists
self.client.login(username= 'ProjectOwner', password= 'top_secret')
response = self.client.get('/projects/' + str(Project.objects.last().pk) + '/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['project'], self.edit_project_test_project)
# Test edit project description
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_project': True,
})
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_project': True,
'project_description': 'edited',
f'task{self.edit_project_test_task1.id}_budget': '40',
f'task{self.edit_project_test_task1.id}_description': 'edited task',
f'task{self.edit_project_test_task2.id}_budget': '40',
f'task{self.edit_project_test_task2.id}_description': 'edited task',
})
#self.assertEqual(response.context['project'].description, 'edited')
def test_edit_project_tasks_description(self):
#TODO
......
......@@ -107,7 +107,7 @@ def project_view(request, project_id):
if request.method == 'POST' and 'edit_project' in request.POST:
edit_project_form = EditProjectForm(request.POST)
if edit_project_form.is_valid():
if edit_project_form.is_valid() and project.status == 'o':
if project.edit:
project.description = request.POST['project_description']
for task in tasks:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment