Removed the jokes / added the reviewer name to the single +1 response.
[margebot.git] / tests / test_marge.py
index d8b85b3..defbed9 100644 (file)
@@ -14,12 +14,12 @@ import logging
 import json
 from queue import Empty
 
-import gitlab
 from dateutil.relativedelta import relativedelta
 import pytest
 import requests
 import errbot
 from errbot.backends.test import testbot   # pylint: disable=unused-import
+import gitlab
 from plugins.marge import deltastr
 
 
@@ -87,12 +87,22 @@ class TestMarge(object):
         def mock_getmergerequest(self, project, iid):
             return {'author': {'id': 2001},
                     'created_at': 'Oct 29, 2017 2:37am',
+                    'iid': 1,
                     'merge_status': 'can_be_merged',
                     'state': 'opened',
+                    'target_project_id': 1,
                     'upvotes': 1,
                     'web_url': 'http://gitlab.example.com/sample/mr/2001',
                     'work_in_progress': False}
         monkeypatch.setattr(gitlab.Gitlab, 'getmergerequest', mock_getmergerequest)
+
+        def mock_getawardemoji(self, project, iid):
+            return [{'name': 'happycat',
+                     'user': {'username': 'ReviewerY'}},
+                    {'name': 'thumbsup',
+                     'user': {'username': 'ReviewerX'}}]
+        monkeypatch.setattr(gitlab.Gitlab, 'getawardemoji', mock_getawardemoji)
+
         return margebot_one_review
 
     @pytest.fixture
@@ -249,16 +259,6 @@ class TestMarge(object):
         assert '!reviews' in help_message
         assert '!watchrepo' in help_message
 
-    def test_good_bot(self, margebot):
-        margebot.push_message('good bot')
-        assert 'Best bot' in margebot.pop_message()
-
-#    def test_xyzzy(self, margebot):
-#        margebot.push_message('!xyzzy')
-#        assert 'All open MRs have been merged into master' in margebot.pop_message()
-#        time.sleep(6)
-#        assert 'just kidding' in margebot.pop_message()
-
     def test_webstatus(self, margebot):
         margebot.push_message('!webstatus')
         assert 'margebot/<rooms>' in margebot.pop_message()
@@ -379,7 +379,7 @@ class TestMarge(object):
         output = margebot.pop_message()
         assert 'These MRs need some attention' in output
         assert 'http://gitlab.example.com/sample/mr/2001' in output
-        assert 'Waiting for another upvote.' in output
+        assert 'Approved by ReviewerX and waiting for another upvote.' in output
 
     def test_get_one_mergable_mr(self, margebot, one_mergable_review, gitlab):
         one_mergable_review.push_message('!reviews')
@@ -407,18 +407,6 @@ class TestMarge(object):
         assert 'These MRs need some attention' in output
         assert 'http://gitlab.example.com/sample/mr/2001 (opened' in output
 
-    def test_dont_blame_margebot(self, margebot):
-        margebot.push_message('I blame margebot')
-        assert "say it ain't so" in margebot.pop_message()
-
-    def test_margefest(self, margebot):
-        margebot.push_message('magfest')
-        assert 'MargeFest' in margebot.pop_message()
-
-    def test_margebot_sucks(self, margebot):
-        margebot.push_message('margebot sucks')
-        assert 'steering committee' in margebot.pop_message()
-
     def test_margebot_unknown_command(self, margebot):
         margebot.push_message('Margebot, alacazam')
         with pytest.raises(Empty):