Merge Request #87

Merged
softwarepublico/colab!87
Created by Gustavo Jaruga Cruz

Fix gitlab links

Fix iid, add tests to iid.

Merged by Lucas Kanashiro

Source branch has been removed
Commits (3)
4 participants
colab/plugins/gitlab/migrations/0005_auto_20150806_1230.py 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +# -*- coding: utf-8 -*-
  2 +from __future__ import unicode_literals
  3 +
  4 +from django.db import models, migrations
  5 +
  6 +
  7 +class Migration(migrations.Migration):
  8 +
  9 + dependencies = [
  10 + ('gitlab', '0004_auto_20150630_1149'),
  11 + ]
  12 +
  13 + operations = [
  14 + migrations.RemoveField(
  15 + model_name='gitlabcomment',
  16 + name='iid',
  17 + ),
  18 + migrations.AddField(
  19 + model_name='gitlabissue',
  20 + name='iid',
  21 + field=models.IntegerField(null=True),
  22 + preserve_default=True,
  23 + ),
  24 + ]
colab/plugins/gitlab/models.py
@@ -64,6 +64,7 @@ class GitlabMergeRequest(Collaboration): @@ -64,6 +64,7 @@ class GitlabMergeRequest(Collaboration):
64 class GitlabIssue(Collaboration): 64 class GitlabIssue(Collaboration):
65 65
66 id = models.IntegerField(primary_key=True) 66 id = models.IntegerField(primary_key=True)
  67 + iid = models.IntegerField(null=True)
67 project = models.ForeignKey(GitlabProject, null=True, 68 project = models.ForeignKey(GitlabProject, null=True,
68 on_delete=models.SET_NULL) 69 on_delete=models.SET_NULL)
69 title = models.TextField() 70 title = models.TextField()
@@ -82,7 +83,7 @@ class GitlabIssue(Collaboration): @@ -82,7 +83,7 @@ class GitlabIssue(Collaboration):
82 @property 83 @property
83 def url(self): 84 def url(self):
84 return u'/gitlab/{}/issues/{}'.format( 85 return u'/gitlab/{}/issues/{}'.format(
85 - self.project.path_with_namespace, self.id) 86 + self.project.path_with_namespace, self.iid)
86 87
87 class Meta: 88 class Meta:
88 verbose_name = _('Gitlab Issue') 89 verbose_name = _('Gitlab Issue')
@@ -92,7 +93,6 @@ class GitlabIssue(Collaboration): @@ -92,7 +93,6 @@ class GitlabIssue(Collaboration):
92 class GitlabComment(Collaboration): 93 class GitlabComment(Collaboration):
93 94
94 id = models.IntegerField(primary_key=True) 95 id = models.IntegerField(primary_key=True)
95 - iid = models.IntegerField(null=True)  
96 body = models.TextField() 96 body = models.TextField()
97 created_at = models.DateTimeField(blank=True, null=True) 97 created_at = models.DateTimeField(blank=True, null=True)
98 issue_comment = models.BooleanField(default=True) 98 issue_comment = models.BooleanField(default=True)
@@ -139,7 +139,7 @@ class GitlabComment(Collaboration): @@ -139,7 +139,7 @@ class GitlabComment(Collaboration):
139 url_str = u'/gitlab/{}/merge_requests/{}#notes_{}' 139 url_str = u'/gitlab/{}/merge_requests/{}#notes_{}'
140 140
141 return url_str.format(self.project.path_with_namespace, 141 return url_str.format(self.project.path_with_namespace,
142 - self.parent_id, self.iid) 142 + self.parent_id, self.id)
143 143
144 class Meta: 144 class Meta:
145 verbose_name = _('Gitlab Comments') 145 verbose_name = _('Gitlab Comments')
colab/plugins/gitlab/tests/test_gitlab.py
@@ -24,9 +24,9 @@ class GitlabTest(TestCase): @@ -24,9 +24,9 @@ class GitlabTest(TestCase):
24 pass 24 pass
25 25
26 def test_data_integrity(self): 26 def test_data_integrity(self):
27 - self.assertEqual(GitlabProject.objects.all().count(), 1)  
28 - self.assertEqual(GitlabMergeRequest.objects.all().count(), 1)  
29 - self.assertEqual(GitlabIssue.objects.all().count(), 1) 27 + self.assertEqual(GitlabProject.objects.all().count(), 2)
  28 + self.assertEqual(GitlabMergeRequest.objects.all().count(), 2)
  29 + self.assertEqual(GitlabIssue.objects.all().count(), 2)
30 self.assertEqual(GitlabComment.objects.all().count(), 2) 30 self.assertEqual(GitlabComment.objects.all().count(), 2)
31 31
32 def test_project_url(self): 32 def test_project_url(self):
@@ -34,55 +34,92 @@ class GitlabTest(TestCase): @@ -34,55 +34,92 @@ class GitlabTest(TestCase):
34 '/gitlab/softwarepublico/colab') 34 '/gitlab/softwarepublico/colab')
35 35
36 def test_merge_request_url(self): 36 def test_merge_request_url(self):
37 - self.assertEqual(GitlabMergeRequest.objects.get(iid=1).url, 37 + self.assertEqual(GitlabMergeRequest.objects.get(id=1).url,
38 '/gitlab/softwarepublico/colab/merge_requests/1') 38 '/gitlab/softwarepublico/colab/merge_requests/1')
  39 + self.assertEqual(GitlabMergeRequest.objects.get(id=2).url,
  40 + '/gitlab/softwarepublico/colabinc/merge_requests/1')
39 41
40 def test_issue_url(self): 42 def test_issue_url(self):
41 self.assertEqual(GitlabIssue.objects.get(id=1).url, 43 self.assertEqual(GitlabIssue.objects.get(id=1).url,
42 '/gitlab/softwarepublico/colab/issues/1') 44 '/gitlab/softwarepublico/colab/issues/1')
  45 + self.assertEqual(GitlabIssue.objects.get(id=2).url,
  46 + '/gitlab/softwarepublico/colabinc/issues/1')
43 47
44 def test_comment_on_mr_url(self): 48 def test_comment_on_mr_url(self):
45 url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1' 49 url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1'
46 - self.assertEqual(GitlabComment.objects.get(iid=1).url, url) 50 + self.assertEqual(GitlabComment.objects.get(id=1).url, url)
47 51
48 def test_comment_on_issue_url(self): 52 def test_comment_on_issue_url(self):
49 self.assertEqual(GitlabComment.objects.get(id=2).url, 53 self.assertEqual(GitlabComment.objects.get(id=2).url,
50 '/gitlab/softwarepublico/colab/issues/1#notes_2') 54 '/gitlab/softwarepublico/colab/issues/1#notes_2')
51 55
52 def create_gitlab_data(self): 56 def create_gitlab_data(self):
53 - g = GitlabProject()  
54 - g.id = 1  
55 - g.name = "colab"  
56 - g.name_with_namespace = "Software Public / Colab"  
57 - g.path_with_namespace = "softwarepublico/colab"  
58 - g.created_at = datetime.now()  
59 - g.last_activity_at = datetime.now()  
60 - g.save()  
61 -  
62 - mr = GitlabMergeRequest()  
63 - mr.iid = 1  
64 - mr.project = g  
65 - mr.title = "Include plugin support"  
66 - mr.description = "Merge request for plugin support"  
67 - mr.state = "Closed"  
68 - mr.created_at = datetime.now()  
69 - mr.update_user(self.user.username)  
70 - mr.save()  
71 -  
72 - i = GitlabIssue()  
73 - i.id = 1  
74 - i.project = g  
75 - i.title = "Issue for colab"  
76 - i.description = "Issue reported to colab"  
77 - i.created_at = datetime.now()  
78 - i.state = "Open"  
79 - i.update_user(self.user.username)  
80 - i.save() 57 + g1 = GitlabProject()
  58 + g1.id = 1
  59 + g1.name = "colab"
  60 + g1.name_with_namespace = "Software Public / Colab"
  61 + g1.path_with_namespace = "softwarepublico/colab"
  62 + g1.created_at = datetime.now()
  63 + g1.last_activity_at = datetime.now()
  64 + g1.save()
  65 +
  66 + g2 = GitlabProject()
  67 + g2.id = 2
  68 + g2.name = "colabinc"
  69 + g2.name_with_namespace = "Software Public / ColabInc"
  70 + g2.path_with_namespace = "softwarepublico/colabinc"
  71 + g2.created_at = datetime.now()
  72 + g2.last_activity_at = datetime.now()
  73 + g2.save()
  74 +
  75 + mr1 = GitlabMergeRequest()
  76 + mr1.id = 1
  77 + mr1.iid = 1
  78 + mr1.project = g1
  79 + mr1.title = "Include plugin support"
  80 + mr1.description = "Merge request for plugin support"
  81 + mr1.state = "Closed"
  82 + mr1.created_at = datetime.now()
  83 + mr1.update_user(self.user.username)
  84 + mr1.save()
  85 +
  86 + mr2 = GitlabMergeRequest()
  87 + mr2.id = 2
  88 + mr2.iid = 1
  89 + mr2.project = g2
  90 + mr2.title = "Include test support"
  91 + mr2.description = "Merge request for test support"
  92 + mr2.state = "Closed"
  93 + mr2.created_at = datetime.now()
  94 + mr2.update_user(self.user.username)
  95 + mr2.save()
  96 +
  97 + i1 = GitlabIssue()
  98 + i1.id = 1
  99 + i1.iid = 1
  100 + i1.project = g1
  101 + i1.title = "Issue for colab"
  102 + i1.description = "Issue reported to colab"
  103 + i1.created_at = datetime.now()
  104 + i1.state = "Open"
  105 + i1.update_user(self.user.username)
  106 + i1.save()
  107 +
  108 + i2 = GitlabIssue()
  109 + i2.id = 2
  110 + i2.iid = 1
  111 + i2.project = g2
  112 + i2.title = "Issue for colab"
  113 + i2.description = "Issue reported to colab"
  114 + i2.created_at = datetime.now()
  115 + i2.state = "Open"
  116 + i2.update_user(self.user.username)
  117 + i2.save()
81 118
82 c1 = GitlabComment() 119 c1 = GitlabComment()
83 - c1.iid = 1  
84 - c1.parent_id = mr.iid  
85 - c1.project = g 120 + c1.id = 1
  121 + c1.parent_id = mr1.iid
  122 + c1.project = g1
86 c1.body = "Comment to merge request" 123 c1.body = "Comment to merge request"
87 c1.created_at = datetime.now() 124 c1.created_at = datetime.now()
88 c1.issue_comment = False 125 c1.issue_comment = False
@@ -90,9 +127,9 @@ class GitlabTest(TestCase): @@ -90,9 +127,9 @@ class GitlabTest(TestCase):
90 c1.save() 127 c1.save()
91 128
92 c2 = GitlabComment() 129 c2 = GitlabComment()
93 - c2.iid = 2  
94 - c2.parent_id = i.id  
95 - c2.project = g 130 + c2.id = 2
  131 + c2.parent_id = i1.id
  132 + c2.project = g1
96 c2.body = "Comment to issue" 133 c2.body = "Comment to issue"
97 c2.created_at = datetime.now() 134 c2.created_at = datetime.now()
98 c2.issue_comment = True 135 c2.issue_comment = True
  • F1c4e7359f83d87a9b8ffc5a003e9cc9?s=40&d=identicon
    Alexandre Barbosa @alexandre

    Reassigned to @lucasmoura

    Choose File ...   File name...
    Cancel
  • 69e14f84c1a9ad76056d75bce2024168?s=40&d=identicon
    Lucas Moura @lucasmoura
  • Def69c998857099b7bc246389e6ad936?s=40&d=identicon
    Lucas Kanashiro @kanashiro

    Added 68 new commits:

    • 3e43c7db - Refactored colab-admin command
    • 13321ea3 - Reducing celery concurrency on local env
    • 4a4ddcb1 - Added init script for celery beat
    • 7ba7f4e6 - Importing data asynchronously
    • a12566bc - Data import moved to celery
    • 57470863 - Fixed pep8
    • e0dc6a6c - Removed PROXIED_APPS (replaced by COLAB_APPS)
    • 31e49bf3 - Renamed ColabProxiedAppConfig to ColabPluginAppConfig
    • d19c324f - Set task name manually
    • 1efa7b87 - Splitted gitlab imports to allow async workers
    • 540555ad - Refactored plugins to remove reference to proxy
    • 9c502ce5 - Fixed to only call tasks if fetch_data is not abstract
    • 1a166d1d - Removed unused import
    • 64781e7e - Allow full plugins on /etc/colab/plugins.d
    • 34773388 - Moved from rabbitmq to redis
    • 8a883b80 - Implemented locking to allow only one importing task at time
    • c548b5aa - Fix redis installation on centos
    • 0b348292 - Change settings.yaml to settings.py
    • 4cb38792 - Change periodic task to 60 seconds
    • 8440c81e - Merge pull request #58 from colab/refactor-data-import
    • b642d938 - Added better strategy for bootstrap hide elements
    • 709bf66a - Merge branch 'fix_merge_button' into 'master'
    • 152ebd04 - Add colab documentation for installation
    • 5037930f - Update user documentation
    • fe35cecc - Merge branch 'documentation' into 'master'
    • 698f2840 - Add celery to colab
    • 9773eddc - Add celery service
    • 5975ae7b - Create structure for colab signals
    • f1ff2fc7 - colab.signals: raise exception in send method
    • 508468fc - colab.signals: Making signal methods global
    • 4423a4f6 - Overwrite reduce parameter of Signal
    • 3c820045 - Create example of plugin using signals structure
    • d1286481 - Creating documentation for signals
    • c811c353 - Create abstract signal class for plugins
    • 7b743f36 - Update plugins dev documentation
    • 5af82b0a - Fixing signals test
    • 9f9d3466 - Solr not needed
    • 2f08f0d5 - Fixed PEP8
    • fe71a2b1 - Using custom exception
    • 502ba6f4 - Moved abstractsignal methods to abstractmethod
    • d6f2d2fb - Extending object
    • 29117f5a - django-celery not needed
    • 15e7387a - Fixed flake8 warnings/errors
    • 011124d4 - Fixed celery imports
    • 5971df7b - Add comment to reducer function on colab.signals
    • fac44a85 - Fix colab.signals tests
    • c30d7a00 - Added logging for settings initialization
    • 96c9b143 - Fixed signals implementation
    • b883fd46 - Removed "leftovers"
    • bf316bce - Refactored signals connections
    • 8570d70e - Create test for signals on colab.plugins.utils
    • e90428a9 - Update doc of plugins signals
    • 7fe0d78a - Remove unused import in test signals
    • 6c215efe - Remove signals.py from plugin dev documentation
    • 169689f7 - Fix signals in plugins.utils and plugins.gitlab
    • 60aef4af - Merge pull request #56 from colab/colab-signals
    • fd747671 - Merge branch 'master' of github.com:colab/colab
    • 721677c8 - Added warning when trying to import plugin from wrong path
    • 37c091d6 - Fixed way to build verification url
    • 566ca024 - Made sending verification email return status
    • 85cc285d - Merge branch 'fix_verification_url' into 'master'
    • d877c831 - Fix app_label in COLAB_APPS
    • 2c6621f8 - Merge branch 'fix_plugins_app_label' into 'master'
    • 86609bf9 - Fixing app_name in colab/utils/conf.py
    • bdd65848 - Merge branch 'fixing_app_name' into 'master'
    • 49b30092 - Fix issue iid
    • b8a689de - Add gitlab url test for iid
    • 8eaa72e7 - Fix tests
    Choose File ...   File name...
    Cancel
  • Def69c998857099b7bc246389e6ad936?s=40&d=identicon
    Lucas Kanashiro @kanashiro
    Choose File ...   File name...
    Cancel