test_scholarhip_validate.py 625 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.test import TestCase
2
from backend.models.scholarship import ScholarshipSerializer
Florent Chehab's avatar
Florent Chehab committed
3
4
5
6
7
8
9
10
import pytest
from rest_framework.validators import ValidationError


class ScholarshipTestCase(TestCase):

    def test_scholarhip_validation(self):
        ser = ScholarshipSerializer()
11
12
13
14
        attrs = {
            'usefull_links': [],
            'comment': ''
        }
Florent Chehab's avatar
Florent Chehab committed
15
        with pytest.raises(ValidationError):
16
17
            attrs['amount_min'] = 200
            attrs['amount_max'] = 100
Florent Chehab's avatar
Florent Chehab committed
18
19
            ser.my_validate(attrs)

20
21
        attrs['amount_min'] = 100
        attrs['amount_max'] = 200
Florent Chehab's avatar
Florent Chehab committed
22
        ser.my_validate(attrs)