def testMatchFailed(self):
     clt = sheriff_config_client.SheriffConfigClient()
     clt._session = self._Session(
         self._Response(False, 'some error message'))
     res, err_msg = clt.Match('Foo2/a/Bar2/b')
     self.assertIsNone(res)
     self.assertIn('some error message', err_msg)
 def testMatch(self):
     clt = sheriff_config_client.SheriffConfigClient()
     response_text = """
 {
   "subscriptions": [
     {
       "config_set": "projects/catapult",
       "revision": "c9d4943dc832e448f9786e244f918fdabc1e5303",
       "subscription": {
         "name": "Public Team1",
         "rotation_url": "https://some/url",
         "notification_email": "*****@*****.**",
         "monorail_project_id": "non-chromium",
         "bug_labels": [
           "Lable1",
           "Lable2"
         ],
         "bug_components": [
           "foo>bar"
         ],
         "visibility": "PUBLIC",
         "patterns": [
           {
             "glob": "Foo2/*/Bar2/*"
           },
           {
             "regex": ".*"
           }
         ]
       }
     }
   ]
 }
 """
     clt._session = self._Session(self._Response(True, response_text))
     expected = [
         Subscription(
             revision='c9d4943dc832e448f9786e244f918fdabc1e5303',
             name='Public Team1',
             rotation_url='https://some/url',
             notification_email='*****@*****.**',
             visibility=VISIBILITY.PUBLIC,
             bug_labels=['Lable1', 'Lable2'],
             bug_components=['foo>bar'],
             auto_triage_enable=False,
             auto_bisect_enable=False,
             monorail_project_id='non-chromium',
         ),
     ]
     self.assertEqual(clt.Match('Foo2/a/Bar2/b'), (expected, None))
 def testMatchFailedCheck(self):
     clt = sheriff_config_client.SheriffConfigClient()
     clt._session = self._Session(
         self._Response(False, 'some error message'))
     with self.assertRaises(sheriff_config_client.InternalServerError):
         clt.Match('Foo2/a/Bar2/b', check=True)