Commit 85b3b502 authored by Ola Hermann Opheim's avatar Ola Hermann Opheim
Browse files

added finished tests

parent a3648f09
......@@ -296,14 +296,14 @@
class="form-control"
>{{offer.price}}</textarea>
{% csrf_token %}
<input type="hidden" name="taskofferid" value="{{offer.id}}">
<input type="hidden" name="offer_id" value="{{offer.id}}">
<button class="btn btn-primary" name="edit_offer" type="submit">Save</button>
</form>
{% else %}
<form method="post">
<p>Description: <br> {{offer.description}}</p>
<p>Price offered: {{offer.price}} </p>
<input type="hidden" name="taskofferid" value="{{offer.id}}">
<input type="hidden" name="offer_id" value="{{offer.id}}">
{% csrf_token %}
<button class="btn btn-primary" name="edit_offer" type="submit" onclick="$('#modal').modal({'backdrop': 'static'});">Edit</button>
</form>
......
......@@ -44,6 +44,15 @@ class ProjectTest(unittest.TestCase):
feedback=''
)
self.edit_offer_test_offer = TaskOffer.objects.create(
task=self.testTask,
title='Test offer 1',
description='original',
price=20,
offerer=self.userNormal.profile,
edit=True
)
# Test project_view GET route
self.client.get('/projects/' + str(Project.objects.last().pk) + '/')
......@@ -58,31 +67,22 @@ class ProjectTest(unittest.TestCase):
})
# Test project_view POST route edit offer
"""
TODO: FIX
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_offer': '',
'taskofferid': 0,
})
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_offer': '',
'taskofferid': 0,
'offer_id': self.edit_offer_test_offer.id,
'offer_description': 'edited',
'offer_price': 30,
'offer_price': '30',
})
"""
# Test project_view POST route offer response
self.client.login(username= 'Owner', password= 'top_secret')
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'offer_response': True,
'taskofferid': 0,
'taskofferid': self.edit_offer_test_offer.id,
'status': 'a',
'feedback': 'ja',
})
# Test project_view POST route edit project
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_project': True,
......@@ -318,7 +318,8 @@ class EditTaskOfferTest(unittest.TestCase):
title='Test offer 1',
description='original',
price=20,
offerer=self.offerer.profile
offerer=self.offerer.profile,
edit=True
)
def test_edit_offer(self):
......@@ -328,23 +329,17 @@ class EditTaskOfferTest(unittest.TestCase):
self.assertEqual(self.edit_offer_test_offer.price, 20)
# Test edit
"""
TODO:FIX
self.client.login(username= 'Offerer', password= 'top_secret')
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_offer': True,
'taskofferid': self.edit_offer_test_offer.id,
})
self.client.post('/projects/' + str(Project.objects.last().pk) + '/', {
'edit_offer': True,
'taskofferid': self.edit_offer_test_offer.id,
'edit_offer': '',
'offer_id': self.edit_offer_test_offer.id,
'offer_description': 'edited',
'offer_price': 30,
})
self.assertEqual(self.edit_offer_test_offer.description, 'edited')
self.assertEqual(self.edit_offer_test_offer.price, 30)
"""
offer = TaskOffer.objects.get(id=self.edit_offer_test_offer.id)
self.assertEqual(offer.description, 'edited')
self.assertEqual(offer.price, 30)
class EditProjectTest(unittest.TestCase):
def setUp(self):
self.client = Client()
......@@ -413,4 +408,3 @@ class EditProjectTest(unittest.TestCase):
self.assertEqual(response.context['tasks'][0].budget, 40)
self.assertEqual(response.context['tasks'][1].description, 'edited task2')
self.assertEqual(response.context['tasks'][1].budget, 50)
\ No newline at end of file
......@@ -101,7 +101,6 @@ def project_view(request, project_id):
project = offer_response.task.project
project.participants.add(offer_response.offerer)
offer_response.save()
offer_response_form = TaskOfferResponseForm()
......@@ -147,7 +146,7 @@ def project_view(request, project_id):
if request.method == 'POST' and 'edit_offer' in request.POST:
edit_task_offer_form = EditTaskOfferForm(request.POST)
if edit_task_offer_form.is_valid():
offer = TaskOffer.objects.get(id=request.POST.get('taskofferid'))
offer = TaskOffer.objects.get(id=request.POST.get('offer_id'))
if offer.status == 'p' and request.user == offer.offerer.user:
if offer.edit:
offer.description = request.POST['offer_description']
......
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