1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 | from django.test.testcases import TestCase
from django.utils.simplejson import loads
from models import Repository
GITHUB = """{
"before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
"repository": {
"url": "http://github.com/defunkt/github",
"name": "github",
"description": "You're lookin' at it.",
"watchers": 5,
"forks": 2,
"private": 1,
"owner": {
"email": "chris@ozmm.org",
"name": "defunkt"
}
},
"commits": [
{
"id": "41a212ee83ca127e3c8cf465891ab7216a705f59",
"url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
"author": {
"email": "chris@ozmm.org",
"name": "Chris Wanstrath"
},
"message": "okay i give in",
"timestamp": "2008-02-15T14:57:17-08:00",
"added": ["filepath.rb"]
},
{
"id": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
"author": {
"email": "chris@ozmm.org",
"name": "Chris Wanstrath"
},
"message": "update pricing a tad",
"timestamp": "2008-02-15T14:36:34-08:00"
}
],
"after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
"ref": "refs/heads/master"
}"""
"""{'broker': u'twitter',
'commits': [{ 'author': u'jespern',
'files': [{'file': u'media/css/layout.css',
'type': u'modified'},
{'file': u'apps/bb/views.py',
'type': u'modified'},
{'file': u'templates/issues/issue.html',
'type': u'modified'}],
'message': u'adding bump button, issue #206 fixed',
'node': u'e71c63bcc05e',
'revision': 1650,
'size': 684}],
'repository': { 'absolute_url': u'/jespern/bitbucket/',
'name': u'bitbucket',
'owner': u'jespern',
'slug': u'bitbucket',
'website': u'http://bitbucket.org/'},
'service': {'password': u'bar', u'username': u'foo'}}"""
BITBUCKET = """{
"commits": [{
"node": "a1baa00061d7",
"files": [{
"type": "modified",
"file": "README.rst"
}],
"author": "justquick",
"timestamp": "2009-09-27 00:09:25",
"branch": "default",
"message": "spapce",
"revision": 9,
"size": 1
}],
"repository": {
"owner": "justquick",
"website": "",
"slug": "django-mptt-comments",
"name": "django-mptt-comments",
"absolute_url": "/justquick/django-mptt-comments/"
},
"user": "justquick"
}"""
GOOGLECODE = """{
"repository_path":"http://asyncwsgi.googlecode.com/svn/",
"project_name":"asyncwsgi",
"revisions":[{
"added":["/trunk/README"],
"author":"justquick",
"url":"http://asyncwsgi.googlecode.com/svn-history/r2/",
"timestamp":1254003348,
"modified":[],
"path_count":1,
"message":"readme\\n",
"removed":[],
"revision":2
}],
"revision_count":1
}"""
def index():
return ( Repository.objects.from_post('github',loads(GITHUB)),
Repository.objects.from_post('bitbucket',loads(BITBUCKET)),
Repository.objects.from_post('googlecode',loads(GOOGLECODE)) )
class POSTParseTest(TestCase):
def test_post(self):
index()
|