Commit 6d6b749c authored by Ola Hermann Opheim's avatar Ola Hermann Opheim
Browse files

added boundary test on giving project offer

parent 934ebdd8
......@@ -165,6 +165,198 @@ class UserTaskPermissionStatementTest(unittest.TestCase):
get_user_task_permissions(self.userHired, response.context['tasks'][0])
# Task 3 - I
class GiveTaskOfferBoundaryTest(unittest.TestCase):
def setUp(self):
self.client = Client()
self.testCategory = ProjectCategory.objects.create(name='test1')
def test_boundary_give_offer(self):
self.userBoundaryOwner = User.objects.create_user(
username='BoundOw',
email='test@test.com',
password='top_secret'
)
self.userBoundaryOfferer = User.objects.create_user(
username='BoundOff',
email='test@test.com',
password='top_secret'
)
self.testBoundaryProject = Project.objects.create(
user=self.userBoundaryOwner.profile,
title="Test project",
description='',
category=self.testCategory,
status='o'
)
self.testBoundaryTask = Task.objects.create(
project=self.testBoundaryProject,
title='Test task',
description='',
budget=20,
status='ad',
feedback=''
)
title_200char = "NNEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
des_500char = "NNEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPGWwOaXChNueq2bq12qrlS6S0YPHkku3JsfYo2BPWOhkNNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueNNEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNueq2bq12qrlS6S0YPkku3JsfYo2BPWOhkNFRLRGi2KoOtEcOLJyGWwOaXChNue"
self.client.login(username= 'BoundOff', password= 'top_secret')
# Test title boundary values by check if list of offers extends
# title 0 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': "",
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers)
# title 1 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': "A",
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# title 199 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': title_200char,
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# title 200 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': title_200char[:-1],
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# title 201 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': (title_200char + "A"),
'description': 'max 500',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers)
# Test description boundary values by check if list of offers extends
# description 0 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': '',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers)
# description 1 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': 'A',
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# description 499 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': des_500char[:-1],
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# description 500 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': des_500char,
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# description 501 chars
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': des_500char + "A",
'price': 123,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers)
# Test price boundary values by check if list of offers extends
# price -1
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': 'description',
'price': -1,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
# TODO: self.assertEqual(TaskOffer.objects.count(), nr_of_offers)
# price 0
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': 'description',
'price': 0,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# price 1
nr_of_offers = TaskOffer.objects.count()
self.client.post(f'/projects/{self.testBoundaryProject.pk}/', {
'title': 'title',
'description': 'description',
'price': 1,
'taskvalue': self.testBoundaryTask.id,
'offer_submit': True
})
self.assertEqual(TaskOffer.objects.count(), nr_of_offers+1)
# Task 3 - II
class AcceptingOfferOutputTest(unittest.TestCase):
def setUp(self):
......
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