File tree Expand file tree Collapse file tree 1 file changed +67
-2
lines changed
Expand file tree Collapse file tree 1 file changed +67
-2
lines changed Original file line number Diff line number Diff line change 1- from django .test import TestCase
1+ from django .test import TestCase , Client
2+ from django .contrib .auth .models import User
23
3- # Create your tests here.
4+ from program .models import ProgramCategory , Proposal
5+
6+
7+ class ProgramApiTest (TestCase ):
8+ def setUp (self ) -> None :
9+ user = User .objects .create ()
10+ user .username = "gdhong"
11+ user .password = "password"
12+ 13+ user .save ()
14+
15+ category = ProgramCategory (
16+ name = "임시" ,
17+ slug = "temp"
18+ )
19+ category .save ()
20+
21+ Proposal (
22+ user = user ,
23+ user_name = "홍길동" ,
24+ title = "세션 제목1" ,
25+ brief = "요약1" ,
26+ desc = "설명1" ,
27+ comment = "comment1" ,
28+ difficulty = "I" ,
29+ duration = "L" ,
30+ language = "K" ,
31+ category = category ,
32+ accepted = True
33+ ).save ()
34+
35+ Proposal (
36+ user = user ,
37+ user_name = "김철수" ,
38+ title = "세션 제목2" ,
39+ brief = "요약2" ,
40+ desc = "설명2" ,
41+ comment = "comment2" ,
42+ difficulty = "I" ,
43+ duration = "L" ,
44+ language = "K" ,
45+ category = category ,
46+ accepted = True
47+ ).save ()
48+
49+ Proposal (
50+ user = user ,
51+ user_name = "badUser" ,
52+ title = "XXXXX" ,
53+ brief = "XXX" ,
54+ desc = "XXX" ,
55+ comment = "XXX" ,
56+ difficulty = "I" ,
57+ duration = "L" ,
58+ language = "K" ,
59+ category = category ,
60+ accepted = False
61+ ).save ()
62+
63+ def test_get_all_session (self ):
64+ c = Client ()
65+ response = c .get ("/api/program/list/" , {})
66+
67+ self .assertEqual (response .status_code , 200 )
68+ self .assertEqual (len (response .data ), 2 )
You can’t perform that action at this time.
0 commit comments