Merge lp:~matiasb/locolander/repo-services-fixes into lp:locolander

Proposed by Matias Bordese
Status: Merged
Merged at revision: 15
Proposed branch: lp:~matiasb/locolander/repo-services-fixes
Merge into: lp:locolander
Diff against target: 128 lines (+33/-15)
4 files modified
locolander/locolanderweb/tests/test_models.py (+1/-1)
locolander/repos/github.py (+7/-4)
locolander/repos/launchpad.py (+1/-1)
locolander/repos/tests/test_github.py (+24/-9)
To merge this branch: bzr merge lp:~matiasb/locolander/repo-services-fixes
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+174577@code.launchpad.net

Commit message

- Fixed LP regex validation.
- Updated GitHub source/target returned values.

Description of the change

- Fixed LP regex validation.
- Updated GitHub source/target returned values.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'locolander/locolanderweb/tests/test_models.py'
--- locolander/locolanderweb/tests/test_models.py 2013-07-06 23:19:29 +0000
+++ locolander/locolanderweb/tests/test_models.py 2013-07-13 19:29:25 +0000
@@ -34,7 +34,7 @@
34 'locolander',34 'locolander',
35 'launchpad.net',35 'launchpad.net',
36 'launchpad.net/foo',36 'launchpad.net/foo',
37 ###'lp:launchpad.net/foo',37 'lp:launchpad.net/foo',
38 'https://github.com/username',38 'https://github.com/username',
39 'git@github.com:foo/dippi-dapi',39 'git@github.com:foo/dippi-dapi',
40)40)
4141
=== modified file 'locolander/repos/github.py'
--- locolander/repos/github.py 2013-06-23 15:12:30 +0000
+++ locolander/repos/github.py 2013-07-13 19:29:25 +0000
@@ -23,6 +23,9 @@
23 # GitHub API access23 # GitHub API access
24 self.gh = GitHub()24 self.gh = GitHub()
2525
26 def _get_clone_url(self, username, repo_name):
27 return "https://github.com/%s/%s.git" % (username, repo_name)
28
26 def _is_approved_comment(self, repo, comment):29 def _is_approved_comment(self, repo, comment):
27 # this is an 'approved' comment by a commiter30 # this is an 'approved' comment by a commiter
28 lines = comment.body.split('\n')31 lines = comment.body.split('\n')
@@ -55,10 +58,10 @@
55 approved.append({58 approved.append({
56 # XXX: needs UTC processing?59 # XXX: needs UTC processing?
57 'date_created': pull.created_at,60 'date_created': pull.created_at,
58 ### 'source_repo': self.gh.repository(*pull.base.repo),61 'source': "%s %s" % (self._get_clone_url(*pull.base.repo),
59 'source': pull.base.ref,62 pull.base.ref),
60 ### 'target_repo': self.gh.repository(*pull.head.repo),63 'target': "%s %s" % (self._get_clone_url(*pull.head.repo),
61 'target': pull.head.ref,64 pull.head.ref),
62 'reviewers': last_comment.user.login, # csv65 'reviewers': last_comment.user.login, # csv
63 'commit_message': commit_message,66 'commit_message': commit_message,
64 })67 })
6568
=== modified file 'locolander/repos/launchpad.py'
--- locolander/repos/launchpad.py 2013-07-06 23:19:29 +0000
+++ locolander/repos/launchpad.py 2013-07-13 19:29:25 +0000
@@ -11,7 +11,7 @@
1111
1212
13CACHE_DIR = os.path.join(os.path.expanduser('~'), '.launchpadlib', 'cache')13CACHE_DIR = os.path.join(os.path.expanduser('~'), '.launchpadlib', 'cache')
14LAUNCHPAD_LP_RE = re.compile(r'^lp:(?:~[^/]+/)?([^/]+)(?:/[^/]+)?$')14LAUNCHPAD_LP_RE = re.compile(r'^lp:(?:~[^/]+/)?([^/\.]+)(?:/[^/]+)?$')
15LAUNCHPAD_HTTPS_RE = re.compile(15LAUNCHPAD_HTTPS_RE = re.compile(
16 r'^http(s)?://launchpad.net/(?:~[^/]+/)?([^/]+)$')16 r'^http(s)?://launchpad.net/(?:~[^/]+/)?([^/]+)$')
1717
1818
=== modified file 'locolander/repos/tests/test_github.py'
--- locolander/repos/tests/test_github.py 2013-07-06 22:26:19 +0000
+++ locolander/repos/tests/test_github.py 2013-07-13 19:29:25 +0000
@@ -25,12 +25,12 @@
25class FakePullRequest(object):25class FakePullRequest(object):
26 """Fake GitHub pull request."""26 """Fake GitHub pull request."""
2727
28 def __init__(self, status=None, is_approved=False):28 def __init__(self, base, head, status=None, is_approved=False):
29 self.is_approved = is_approved29 self.is_approved = is_approved
30 self.status = status30 self.status = status
31 self.created_at = datetime.now()31 self.created_at = datetime.now()
32 self.base = FakeRepo()32 self.base = FakeRepo(name=base)
33 self.head = FakeRepo()33 self.head = FakeRepo(name=head)
3434
35 def iter_issue_comments(self):35 def iter_issue_comments(self):
36 is_collaborator = self.is_approved36 is_collaborator = self.is_approved
@@ -42,8 +42,10 @@
42class FakeRepo(object):42class FakeRepo(object):
43 """Fake GitHub project repo."""43 """Fake GitHub project repo."""
4444
45 def __init__(self, is_approved=False):45 def __init__(self, name, is_approved=False):
46 self.name = name
46 self.is_approved = is_approved47 self.is_approved = is_approved
48 self.repo = ('user', self.name)
47 self.ref = 'master'49 self.ref = 'master'
48 self.status = 'no-approved'50 self.status = 'no-approved'
49 if is_approved:51 if is_approved:
@@ -51,10 +53,11 @@
5153
52 def iter_pulls(self, state):54 def iter_pulls(self, state):
53 if self.is_approved:55 if self.is_approved:
54 pulls = [FakePullRequest(),56 pulls = [FakePullRequest('source', self.name),
55 FakePullRequest(status='approved', is_approved=True)]57 FakePullRequest('source', self.name,
58 status='approved', is_approved=True)]
56 else:59 else:
57 pulls = [FakePullRequest()]60 pulls = [FakePullRequest('source', self.name)]
58 return pulls61 return pulls
5962
60 def is_collaborator(self, username):63 def is_collaborator(self, username):
@@ -67,8 +70,8 @@
67 def __init__(self):70 def __init__(self):
68 self.data = {}71 self.data = {}
69 repos = {72 repos = {
70 'test-repo': FakeRepo(is_approved=True),73 'test-repo': FakeRepo(name='test-repo', is_approved=True),
71 'another-repo': FakeRepo(),74 'another-repo': FakeRepo(name='another-repo'),
72 }75 }
73 self.data['test-user'] = repos76 self.data['test-user'] = repos
7477
@@ -116,3 +119,15 @@
116 for key in expected_keys:119 for key in expected_keys:
117 self.assertIn(key, mp)120 self.assertIn(key, mp)
118 self.assertEqual(mp['commit_message'], 'commit msg')121 self.assertEqual(mp['commit_message'], 'commit msg')
122
123 def test_approved_mp_source_target(self):
124 mps = self.gh.approved_requests_for_project_url(
125 'git@github.com:test-user/test-repo.git')
126 self.assertEqual(len(mps), 1)
127 mp = mps[0]
128
129 self.assertIsInstance(mp, dict)
130 self.assertEqual(
131 mp['source'], 'https://github.com/user/source.git master')
132 self.assertEqual(
133 mp['target'], 'https://github.com/user/test-repo.git master')

Subscribers

People subscribed via source and target branches

to all changes: