コード例 #1
0
 def test_returns_fault_if_code_matches_one_of_set(self):
     # trap_fault returns the Fault inside the Failure if the fault code
     # matches even one of the given fault codes.
     failure = self.makeFailure(TestFaultOne)
     fault = trap_fault(failure, TestFaultOne, TestFaultTwo)
     self.assertEqual(TestFaultOne.error_code, fault.faultCode)
     self.assertEqual(TestFaultOne.msg_template, fault.faultString)
コード例 #2
0
 def test_returns_fault_if_code_matches_one_of_set(self):
     # trap_fault returns the Fault inside the Failure if the fault code
     # matches even one of the given fault codes.
     failure = self.makeFailure(TestFaultOne)
     fault = trap_fault(failure, TestFaultOne, TestFaultTwo)
     self.assertEqual(TestFaultOne.error_code, fault.faultCode)
     self.assertEqual(TestFaultOne.msg_template, fault.faultString)
コード例 #3
0
 def test_returns_fault_if_code_matches(self):
     # trap_fault returns the Fault inside the Failure if the fault code
     # matches what's given.
     failure = self.makeFailure(TestFaultOne)
     fault = trap_fault(failure, TestFaultOne)
     self.assertEqual(TestFaultOne.error_code, fault.faultCode)
     self.assertEqual(TestFaultOne.msg_template, fault.faultString)
コード例 #4
0
 def test_returns_fault_if_code_matches(self):
     # trap_fault returns the Fault inside the Failure if the fault code
     # matches what's given.
     failure = self.makeFailure(TestFaultOne)
     fault = trap_fault(failure, TestFaultOne)
     self.assertEqual(TestFaultOne.error_code, fault.faultCode)
     self.assertEqual(TestFaultOne.msg_template, fault.faultString)
コード例 #5
0
 def translate_fault(fail):
     # We turn faults.NotFound into a PermissionDenied, even
     # though one might think that it would make sense to raise
     # NoSuchFile. Sadly, raising that makes the client do "clever"
     # things like say "Parent directory of
     # bzr+ssh://bazaar.launchpad.dev/~noone/firefox/branch does not
     # exist. You may supply --create-prefix to create all leading
     # parent directories", which is just misleading.
     fault = trap_fault(fail, faults.NotFound, faults.PermissionDenied,
                        faults.InvalidSourcePackageName,
                        faults.InvalidProductName)
     faultString = six.ensure_binary(fault.faultString)
     return failure.Failure(
         PermissionDenied(virtual_url_fragment, faultString))
コード例 #6
0
ファイル: branchfs.py プロジェクト: vitaminmoo/unnaturalcode
 def translate_fault(fail):
     # We turn faults.NotFound into a PermissionDenied, even
     # though one might think that it would make sense to raise
     # NoSuchFile. Sadly, raising that makes the client do "clever"
     # things like say "Parent directory of
     # bzr+ssh://bazaar.launchpad.dev/~noone/firefox/branch does not
     # exist. You may supply --create-prefix to create all leading
     # parent directories", which is just misleading.
     fault = trap_fault(
         fail,
         faults.NotFound,
         faults.PermissionDenied,
         faults.InvalidSourcePackageName,
         faults.InvalidProductName,
     )
     faultString = fault.faultString
     if isinstance(faultString, unicode):
         faultString = faultString.encode("utf-8")
     return failure.Failure(PermissionDenied(virtual_url_fragment, faultString))
コード例 #7
0
ファイル: auth.py プロジェクト: vitaminmoo/unnaturalcode
 def _reportNoSuchUser(self, failure, credentials):
     """Report the user named in the credentials not existing nicely."""
     trap_fault(failure, faults.NoSuchPersonWithName)
     raise UserDisplayedUnauthorizedLogin("No such Launchpad account: %s" % credentials.username)
コード例 #8
0
ファイル: branchfs.py プロジェクト: vitaminmoo/unnaturalcode
 def path_not_translated(fail):
     trap_fault(fail, faults.PathTranslationError, faults.PermissionDenied)
     return failure.Failure(NoSuchFile(virtual_url_fragment))
コード例 #9
0
 def path_not_translated(fail):
     trap_fault(fail, faults.PathTranslationError,
                faults.PermissionDenied)
     return failure.Failure(NoSuchFile(virtual_url_fragment))
コード例 #10
0
ファイル: auth.py プロジェクト: pombreda/UnnaturalCodeFork
 def _reportNoSuchUser(self, failure, credentials):
     """Report the user named in the credentials not existing nicely."""
     trap_fault(failure, faults.NoSuchPersonWithName)
     raise UserDisplayedUnauthorizedLogin("No such Launchpad account: %s" %
                                          credentials.username)