File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
styleguide_example/test_examples Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ def student_create(
34
34
roster_create (
35
35
student = student ,
36
36
school_course = school_course ,
37
- start_date = None
37
+ start_date = start_date ,
38
+ end_date = school_course .end_date
38
39
)
39
40
40
41
return student
Original file line number Diff line number Diff line change
1
+ from unittest .mock import patch
2
+
3
+ from django .test import TestCase
4
+
5
+ from styleguide_example .utils .tests import faker
6
+
7
+ from styleguide_example .test_examples .services import student_create
8
+ from styleguide_example .test_examples .tests .factories import SchoolFactory , SchoolCourseFactory
9
+
10
+
11
+ class StudentCreateTests (TestCase ):
12
+ @patch ('styleguide_example.test_examples.services.students.school_list_school_courses' )
13
+ @patch ('styleguide_example.test_examples.services.students.roster_create' )
14
+ def test_student_is_rostered_to_all_active_school_courses (
15
+ self ,
16
+ roster_create_mock ,
17
+ school_courses_mock
18
+ ):
19
+ school = SchoolFactory ()
20
+ start_date = faker .date ()
21
+ email = faker .unique .email ()
22
+
23
+ school_courses_mock .select_related .return_value = SchoolCourseFactory .stub_batch (size = 5 )
24
+
25
+ student = student_create (
26
+ email = email ,
27
+ school = school ,
28
+ start_date = start_date
29
+ )
30
+
31
+ self .assertEqual (student .email , email )
32
+ self .assertEqual (student .school , school )
33
+
34
+ for school_course in school_courses_mock .return_value :
35
+ roster_create_mock .assert_called_with (
36
+ school_course = school_course ,
37
+ student = student ,
38
+ start_date = start_date ,
39
+ end_date = school_course .end_date
40
+ )
You can’t perform that action at this time.
0 commit comments