Spot ’em bugs..!

Spot ’em bugs..!

pip install bugspots3

Hi, guys! This week was filled mostly with surprises. I just moved to Bangalore on Friday, in a hurry.

And as far as Summer of Code is concerned, it was pretty hectic around. I migrated around a couple of plugins on gitmate-2, **bug_spotter** (labels the pull requests with higher bug rate possibility) and **issue_labeller** (labels the issues based on keywords captured from the title and description).

So, there’s this cool package **bugspots3**, which basically implements Google’s bug prediction algorithm. It pretty much predicts the top 10% of error prone files by weighing them based on their age. More info on the algorithm goes here.

Gitmate has it’s own testcase now, hell yeah!

There was a complete redesign on the testing architecture too. We have a **GitmateTestCase** class now, which could be used as a base class for testing gitmate responders. It provides us with a lot of helper methods like **setUpWithPlugin** (sets up all the stuff with the specified plugin), **simulate_github_webhook_call** (simulates the webhook trigger from github to gitmate server), etc. I also finished tests for all the plugins with 100% coverage.

It eases up writing tests a lot now. Here’s one from **gitmate_welcome_commenter** plugin.

from unittest.mock import patch
from IGitt.GitHub.GitHubIssue import GitHubIssue
from rest_framework import status
from gitmate_config.tests.test_base import GitmateTestCase

class TestWelcomeCommenter(GitmateTestCase):
def setUp(self):
super().setUpWithPlugin('welcome_commenter')

@patch.object(GitHubIssue, 'add\_comment', autospec=True)  
def test\_github(self, mock\_add\_comment):  
    data = {  
        'repository': {'full\_name': 'star-wars'},  
        'pull\_request': {'number': 7},  
        'action': 'opened'  
    }  
    response = self.simulate\_github\_webhook\_call('pull\_request',  
                                                 data)  
    self.assertEquals(response.status\_code, status.HTTP\_200\_OK)  
    mock\_add\_comment.assert\_called\_once()

Ugh! Terrible connectivity strikes here..

And most of the tests on **gitmate-2** are network based, which could lead to non-deterministic failure of pipelines. So, next week’s focus would be on mocking external requests with suitable data and providing a completely offline way to run tests.

I guess I pretty much need this ASAP, I’ve terrible network bandwidth around here.

Ok, then, catch ya later, guys!