Ejemplo n.º 1
0
 def test_load_json_wo_sanitization(self):
     data = expected = {'message': 'hello world!!!'}
     with tempfile.TemporaryDirectory() as tempdir:
         filepath = os.path.join(tempdir, 'foo.json')
         with open(filepath, 'w') as file:
             json.dump(data, file)
         actual = helpers.load_json(filepath, sanitize=False)
         self.assertEqual(expected, actual)
Ejemplo n.º 2
0
 def get_reviews(self, year):
     """
     Yield the reviews associated with the specified year.
     """
     directory = self.get_reviews_path(year)
     for path in self._get_files(directory, pattern='reviews.*.json'):
         for review in helpers.load_json(path):
             yield review
Ejemplo n.º 3
0
    def get_review(self, id, year=None):
        """

        """
        year = self.get_year(id, switch='reviews') if year is None else year
        directory = self.get_reviews_path(year)
        for path in self._get_files(directory, pattern='reviews.*.json'):
            reviews = helpers.load_json(path)
            for review in reviews:
                if id == review['issue']:
                    return review
        raise Exception('No code review identified by {}'.format(id))
Ejemplo n.º 4
0
    def get_bugs(self, year):
        """Yield bugs that were published in a specified year.

        Parameters
        ----------
        year : int
            Bugs published in the specified year must be returned.

        Return
        ------
        bugs : generator
            Iterator-like object that allows iteration over the bugs being
            returned without blocking the caller.
        """
        directory = self.get_bugs_path(year)
        for path in self._get_files(directory, pattern='bugs.*.json'):
            for bug in helpers.load_json(path):
                yield bug
Ejemplo n.º 5
0
    def get_bug(self, id, year=None):
        """Retrieve a bug identified by the unique identifier specified.

        Parameters
        ----------
        id : int
            Unique identifier of the bug to retrieve.

        Returns
        -------
        bug : dict
            Bug identified by the identifier specified. An exception is raised
            when no bug was found.
        """
        year = self.get_year(id, switch='bugs') if year is None else year
        directory = self.get_bugs_path(year)
        for path in self._get_files(directory, pattern='bugs.*.json'):
            bugs = helpers.load_json(path)
            for bug in bugs:
                if id == bug['id']:
                    return bug
        raise Exception('No bug identified by {}'.format(id))