Esempio n. 1
0
 def test_convert_to_json_and_back(self):
     bugzilla_formatted_date_string = datetime.today().strftime(
         BUGZILLA_DATE_FORMAT)
     expected_date = datetime.strptime(bugzilla_formatted_date_string,
                                       BUGZILLA_DATE_FORMAT)
     attachment = Attachment({'attach_date': expected_date}, None)
     self.assertEqual(
         Attachment.from_json(attachment.to_json()).attach_date(),
         expected_date)
Esempio n. 2
0
 def fetch_attachment(self, attachment_id):
     # We will neither have metadata nor content if our API key is missing, invalid, or revoked.
     attachment_metadata = self._fetch_attachment_page('metadata', attachment_id)
     if not attachment_metadata:
         return None
     attachment_contents = self._fetch_attachment_page('data', attachment_id)
     if not attachment_contents:
         return None
     attachment = Attachment.from_json(attachment_metadata)
     attachment.contents = lambda: attachment_contents
     return attachment
Esempio n. 3
0
 def test_no_bug_id(self):
     self.assertEqual(Attachment({'id': 12345}, None).bug_id(), None)
 def fetch_attachment(self, attachment_id):
     _log.info('MOCK: fetch_attachment: {}'.format(attachment_id))
     attachment = Attachment({'id': 10008}, None)
     attachment.content = lambda: 'Patch'
     return attachment
 def __init__(self, attachment_dictionary, contents):
     Attachment.__init__(self, attachment_dictionary, self)
     self._contents = contents
Esempio n. 6
0
 def attachments(self, include_obsolete=False):
     attachments = self.bug_dictionary["attachments"]
     if not include_obsolete:
         attachments = filter(
             lambda attachment: not attachment["is_obsolete"], attachments)
     return [Attachment(attachment, self) for attachment in attachments]
Esempio n. 7
0
 def fetch_attachment(self, attachment_id):
     attachment = Attachment({'id': 10008}, None)
     attachment.content = lambda: 'Patch'
     return attachment
 def __init__(self, attachment_dictionary, contents, is_patch, is_obsolete):
     Attachment.__init__(self, attachment_dictionary, self)
     self._contents = contents
     self._is_patch = is_patch
     self._is_obsolete = is_obsolete