11from django .core .management import call_command
22from django .test import TestCase
33
4+ from data .issues import import_issue
5+ from community .git import get_org_name
6+ from data .merge_requests import import_mr
47from gamification .models import (
58 Level ,
69 Badge ,
710 Participant ,
811 BadgeActivity ,
912)
13+ from data .contrib_data import import_data
1014from data .newcomers import active_newcomers
1115
16+ ORG_NAME = get_org_name ()
17+
1218
1319class CreateConfigDataTest (TestCase ):
1420
@@ -79,6 +85,18 @@ class UpdateParticipantsTest(TestCase):
7985
8086 @classmethod
8187 def setUpTestData (cls ):
88+ for contrib in get_false_contributors_data ():
89+ import_data (contrib )
90+
91+ for issue in get_false_issues_data ():
92+ import_issue ('github' , issue )
93+
94+ for mr in get_false_mrs_data ():
95+ import_mr ('github' , mr )
96+
97+ for contrib in get_false_active_newcomers ():
98+ Participant .objects .create (username = contrib ['username' ])
99+
82100 call_command ('import_issues_data' )
83101 call_command ('import_merge_requests_data' )
84102 call_command ('create_config_data' )
@@ -98,3 +116,204 @@ def test_command_update_particiapants_data(self):
98116
99117 number_of_badges = participant .badges .all ().count ()
100118 self .assertEquals (number_of_badges , 2 )
119+
120+
121+ def get_false_contributors_data ():
122+ return [
123+ {
124+ 'bio' : '' ,
125+ 'teams' : [
126+ f'{ ORG_NAME } newcomers'
127+ ],
128+ 'reviews' : 0 ,
129+ 'issues' : 0 ,
130+ 'name' : '' ,
131+ 'login' : 'testuser' ,
132+ 'contributions' : 1
133+ },
134+ {
135+ 'bio' : '' ,
136+ 'teams' : [
137+ f'{ ORG_NAME } newcomers'
138+ ],
139+ 'reviews' : 0 ,
140+ 'issues' : 0 ,
141+ 'name' : '' ,
142+ 'login' : 'testuser' ,
143+ 'contributions' : 1
144+ },
145+ {
146+ 'bio' : '' ,
147+ 'teams' : [
148+ ],
149+ 'reviews' : 0 ,
150+ 'name' : '' ,
151+ 'login' : 'testuser1' ,
152+ 'contributions' : 1
153+ }
154+ ]
155+
156+
157+ def get_false_issues_data ():
158+ return [
159+ {
160+ 'created_at' : '2016-11-21T00:46:14' ,
161+ 'hoster' : 'github' ,
162+ 'updated_at' : '2017-12-21T00:00:48' ,
163+ 'labels' : [
164+ 'status/duplicate'
165+ ],
166+ 'number' : 1 ,
167+ 'assignees' : [],
168+ 'repo_id' : 254525111 ,
169+ 'title' : 'Test issue' ,
170+ 'state' : 'closed' ,
171+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
172+ 'url' : f'https://github.com/{ ORG_NAME } /corobo/issues/585' ,
173+ 'author' : 'testuser'
174+ },
175+ {
176+ 'created_at' : '2016-11-21T00:46:14' ,
177+ 'hoster' : 'github' ,
178+ 'updated_at' : '2017-12-21T00:00:48' ,
179+ 'labels' : [
180+ 'difficulty/newcomer' ,
181+ 'type/bug'
182+ ],
183+ 'number' : 3 ,
184+ 'assignees' : [],
185+ 'repo_id' : 254525111 ,
186+ 'title' : 'Test issue' ,
187+ 'state' : 'closed' ,
188+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
189+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /issues/1' ,
190+ 'author' : 'testuser1'
191+ },
192+ {
193+ 'created_at' : '2016-11-21T00:46:14' ,
194+ 'hoster' : 'github' ,
195+ 'updated_at' : '2017-12-21T00:00:48' ,
196+ 'labels' : [
197+ 'difficulty/newcomer' ,
198+ 'type/bug'
199+ ],
200+ 'number' : 2 ,
201+ 'assignees' : [],
202+ 'repo_id' : 254525111 ,
203+ 'title' : 'Test issue' ,
204+ 'state' : 'closed' ,
205+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
206+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /issues/2' ,
207+ 'author' : 'testuser'
208+ },
209+ {
210+ 'created_at' : '2016-11-21T00:46:14' ,
211+ 'hoster' : 'github' ,
212+ 'updated_at' : '2017-12-21T00:00:48' ,
213+ 'labels' : [
214+ 'difficulty/newcomer' ,
215+ 'type/bug'
216+ ],
217+ 'number' : 2 ,
218+ 'assignees' : [],
219+ 'title' : 'Test issue' ,
220+ 'state' : 'closed' ,
221+ 'repo' : 'test/test' ,
222+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /issues/3' ,
223+ 'author' : 'testuser1'
224+ }
225+ ]
226+
227+
228+ def get_false_mrs_data ():
229+ return [
230+ {
231+ 'created_at' : '2016-02-21T05:04:25' ,
232+ 'hoster' : 'github' ,
233+ 'ci_status' : True ,
234+ 'labels' : [
235+ 'difficulty/newcomer' ,
236+ 'type/bug'
237+ ],
238+ 'title' : 'Test merge request-I' ,
239+ 'number' : 1625 ,
240+ 'updated_at' : '2016-04-21T12:06:19' ,
241+ 'assignees' : [],
242+ 'repo_id' : 254525111 ,
243+ 'closes_issues' : [
244+ 2 ,
245+ 3
246+ ],
247+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
248+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /pull/1625' ,
249+ 'state' : 'merged' ,
250+ 'author' : 'testuser'
251+ },
252+ {
253+ 'created_at' : '2016-02-21T05:04:25' ,
254+ 'hoster' : 'github' ,
255+ 'ci_status' : True ,
256+ 'labels' : [
257+ 'status/STALE'
258+ ],
259+ 'title' : 'Test merge request-II' ,
260+ 'number' : 1626 ,
261+ 'updated_at' : '2016-02-21T12:06:19' ,
262+ 'assignees' : [],
263+ 'repo_id' : 25452511 ,
264+ 'closes_issues' : [
265+ ],
266+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
267+ 'state' : 'merged' ,
268+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /pull/1626' ,
269+ 'author' : 'testuser'
270+ },
271+ {
272+ 'created_at' : '2016-02-21T05:04:25' ,
273+ 'hoster' : 'github' ,
274+ 'ci_status' : True ,
275+ 'labels' : [
276+ 'difficulty/low' ,
277+ 'type/bug'
278+ ],
279+ 'title' : 'Test merge request-III' ,
280+ 'number' : 1626 ,
281+ 'updated_at' : '2016-02-21T12:06:19' ,
282+ 'assignees' : [
283+ 'testuser' ,
284+ 'testuser1'
285+ ],
286+ 'repo_id' : 25452511 ,
287+ 'closes_issues' : [
288+ ],
289+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
290+ 'state' : 'merged' ,
291+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /pull/1625' ,
292+ 'author' : 'testuser'
293+ },
294+ {
295+ 'created_at' : '2016-02-21T05:04:25' ,
296+ 'hoster' : 'github' ,
297+ 'labels' : [
298+ 'difficulty/low' ,
299+ 'type/bug'
300+ ],
301+ 'title' : 'Test merge request-III' ,
302+ 'number' : 1626 ,
303+ 'updated_at' : '2016-02-21T12:06:19' ,
304+ 'assignees' : [],
305+ 'repo_id' : 25452511 ,
306+ 'repo' : f'{ ORG_NAME } /{ ORG_NAME } ' ,
307+ 'url' : f'https://github.com/{ ORG_NAME } /{ ORG_NAME } /pull/1625' ,
308+ 'closes_issues' : [
309+ ],
310+ 'author' : 'testuser1'
311+ }
312+ ]
313+
314+
315+ def get_false_active_newcomers ():
316+ return [
317+ {'username' : 'testuser' },
318+ {'username' : 'testuser1' }
319+ ]
0 commit comments