Beispiel #1
0
 def test_destroy_tag(self):
     request = tag_messages.TagRequest(
         urlsafe_key=self.hidden_tag.key.urlsafe())
     with mock.patch.object(self.service, 'check_xsrf_token',
                            autospec=True) as mock_xsrf_token:
         response = self.service.destroy(request)
         self.assertEqual(mock_xsrf_token.call_count, 1)
         self.assertIsNone(tag_model.Tag.get(self.hidden_tag.key.urlsafe()))
         self.assertIsInstance(response, message_types.VoidMessage)
Beispiel #2
0
 def test_get_tag(self):
     request = tag_messages.TagRequest(
         urlsafe_key=self.test_tag.key.urlsafe())
     expected_response = tag_messages.Tag(
         name=self.test_tag.name,
         hidden=self.test_tag.hidden,
         color=self.test_tag.color,
         protect=self.test_tag.protect,
         description=self.test_tag.description)
     with mock.patch.object(self.service, 'check_xsrf_token',
                            autospec=True) as mock_xsrf_token:
         response = self.service.get(request)
         self.assertEqual(mock_xsrf_token.call_count, 1)
         self.assertEqual(response, expected_response)
Beispiel #3
0
 def test_get_tag_bad_request(self):
     request = tag_messages.TagRequest(urlsafe_key='fake_urlsafe_key')
     with self.assertRaises(endpoints.BadRequestException):
         self.service.get(request)
Beispiel #4
0
 def test_destroy_not_existing(self):
     with self.assertRaises(endpoints.BadRequestException):
         self.service.destroy(
             tag_messages.TagRequest(urlsafe_key='nonexistent_tag'))
Beispiel #5
0
 def test_destroy_protected(self):
     with self.assertRaises(endpoints.BadRequestException):
         self.service.destroy(
             tag_messages.TagRequest(
                 urlsafe_key=self.protected_tag.key.urlsafe()))
 def testTagRequest(self):
     tag_req = tag_messages.TagRequest(urlsafe_key='FAKE-URL-KEY')
     self.assertEqual(tag_req.urlsafe_key, 'FAKE-URL-KEY')