Ejemplo n.º 1
0
 def setUp(self):
     super(ServiceGithubTest, self).setUp()
     self.data = {'content': 'this is the content of the issue;)',
                  'summary_detail': 'a nice issue ;)',
                  'title': 'a nice issue ;)',
                  'description': 'this is the description of the issue'}
     self.token = 'QWERTY123#TH#12345'
     self.trigger_id = 1
     self.service = ServiceGithub(self.token)
Ejemplo n.º 2
0
    def test_read_data(self):
        self.create_github()
        kwargs = dict({'date_triggered': '2013-05-11 13:23:58+00:00',
                       'trigger_id': self.trigger_id,
                       'model_name': 'Github'})

        trigger_id = kwargs.get('trigger_id')

        data = []
        cache.set('th_github_' + str(trigger_id), data)

        with patch('github3.GitHub.ratelimit_remaining',
                   new_callable=PropertyMock) as mock_read_data:
            mock_read_data.return_value = 2
            with patch.object(GitHub, 'issues_on') as mock_read_data2:
                se = ServiceGithub(self.token)
                se.read_data(**kwargs)
                mock_read_data2.assert_called_once()
        mock_read_data.assert_called_once()
Ejemplo n.º 3
0
    def test_read_data(self):
        self.create_github()
        kwargs = dict({'date_triggered': '2013-05-11 13:23:58+00:00',
                       'trigger_id': self.trigger_id,
                       'model_name': 'Github'})

        trigger_id = kwargs.get('trigger_id')

        data = []
        cache.set('th_github_' + str(trigger_id), data)

        with patch('github3.GitHub.ratelimit_remaining',
                   new_callable=PropertyMock) as mock_read_data:
            mock_read_data.return_value = 2
            with patch.object(GitHub, 'issues_on') as mock_read_data2:
                se = ServiceGithub(self.token)
                se.read_data(**kwargs)
                mock_read_data2.assert_called_once()
        mock_read_data.assert_called_once()
Ejemplo n.º 4
0
    def test_save_data(self):
        g = self.create_github()
        token = self.token
        trigger_id = self.trigger_id

        self.assertTrue(token)
        self.assertTrue(isinstance(trigger_id, int))
        self.assertIn('content', self.data)
        self.assertIn('summary_detail', self.data)
        self.assertIn('description', self.data)
        self.assertIn('title', self.data)
        self.assertNotEqual(self.data['title'], '')

        with patch('github3.GitHub.ratelimit_remaining',
                   new_callable=PropertyMock) as mock_save_data:
            mock_save_data.return_value = 2
            with patch.object(GitHub, 'create_issue') as mock_save_data2:
                se = ServiceGithub(self.token)
                se.save_data(self.trigger_id, **self.data)
            mock_save_data2.assert_called_once_with(g.repo, g.project,
                                                    self.data['title'],
                                                    self.data['content'])
        mock_save_data.assert_called_once_with()
Ejemplo n.º 5
0
    def test_save_data(self):
        g = self.create_github()
        token = self.token
        trigger_id = self.trigger_id

        self.assertTrue(token)
        self.assertTrue(isinstance(trigger_id, int))
        self.assertIn('content', self.data)
        self.assertIn('summary_detail', self.data)
        self.assertIn('description', self.data)
        self.assertIn('title', self.data)
        self.assertNotEqual(self.data['title'], '')

        with patch('github3.GitHub.ratelimit_remaining',
                   new_callable=PropertyMock) as mock_save_data:
            mock_save_data.return_value = 2
            with patch.object(GitHub, 'create_issue') as mock_save_data2:
                se = ServiceGithub(self.token)
                se.save_data(self.trigger_id, **self.data)
            mock_save_data2.assert_called_once_with(g.repo,
                                                    g.project,
                                                    self.data['title'],
                                                    self.data['content'])
        mock_save_data.assert_called_once_with()