예제 #1
0
 def test_removal_mixed(self):
     """When multiple items are present in the feed, but only some
     are present in the database.
     """
     # Item 1
     obj_foo = SharedItem()
     self.root.shared['foo_uid'] = obj_foo
     # Create the entries
     feed_items = []
     feed_items.append(XML_ENTRY % ('foo', 'foo_uid'))
     feed_items.append(XML_ENTRY % ('missing', 'missing_uid'))
     feed = XML_WRAPPER % "".join(feed_items)
     # Set up the request
     request = testing.DummyRequest(
         body=feed,
         content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(
         response.body,
         ('Removed 1 items. '
          '1 items could not be found for deletion: missing_uid'),
     )
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('foo_uid', False))
     self.failIf(self.root.shared.get('bar_uid', False))
예제 #2
0
 def test_removal_mixed(self):
     """When multiple items are present in the feed, but only some
     are present in the database.
     """
     # Item 1
     obj_foo = SharedItem()
     self.root.shared['foo_uid'] = obj_foo
     # Create the entries
     feed_items = []
     feed_items.append(XML_ENTRY % ('foo', 'foo_uid'))
     feed_items.append(XML_ENTRY % ('missing', 'missing_uid'))
     feed = XML_WRAPPER % "".join(feed_items)
     # Set up the request
     request = testing.DummyRequest(body=feed,
                                    content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(
         response.body,
         ('Removed 1 items. '
          '1 items could not be found for deletion: missing_uid'),
     )
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('foo_uid', False))
     self.failIf(self.root.shared.get('bar_uid', False))
예제 #3
0
 def test_removal_multiple(self):
     """When multiple items are present in the feed, they will be
     deleted.
     """
     # Item 1
     obj_foo = SharedItem()
     self.root.shared['foo_uid'] = obj_foo
     # Item 2
     obj_bar = SharedItem()
     self.root.shared['bar_uid'] = obj_bar
     # Create the entries
     feed_items = []
     feed_items.append(XML_ENTRY % ('foo', 'foo_uid'))
     feed_items.append(XML_ENTRY % ('bar', 'bar_uid'))
     feed = XML_WRAPPER % "".join(feed_items)
     # Set up the request
     request = testing.DummyRequest(
         body=feed,
         content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(response.body, 'Removed 2 items.')
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('foo_uid', False))
     self.failIf(self.root.shared.get('bar_uid', False))
예제 #4
0
 def test_removal_multiple(self):
     """When multiple items are present in the feed, they will be
     deleted.
     """
     # Item 1
     obj_foo = SharedItem()
     self.root.shared['foo_uid'] = obj_foo
     # Item 2
     obj_bar = SharedItem()
     self.root.shared['bar_uid'] = obj_bar
     # Create the entries
     feed_items = []
     feed_items.append(XML_ENTRY % ('foo', 'foo_uid'))
     feed_items.append(XML_ENTRY % ('bar', 'bar_uid'))
     feed = XML_WRAPPER % "".join(feed_items)
     # Set up the request
     request = testing.DummyRequest(body=feed,
                                    content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(response.body, 'Removed 2 items.')
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('foo_uid', False))
     self.failIf(self.root.shared.get('bar_uid', False))
예제 #5
0
 def test_bad_content_type(self):
     """If a content type other than RSS or Atom is passed in a
     BadRequest is raised
     """
     request = testing.DummyRequest(body='', content_type='text/plain')
     response = delete_items(self.root, request)
     self.assertEquals(response.code, 400)
예제 #6
0
 def test_bad_content_type(self):
     """If a content type other than RSS or Atom is passed in a
     BadRequest is raised
     """
     request = testing.DummyRequest(
         body='',
         content_type='text/plain')
     response = delete_items(self.root, request)
     self.assertEquals(response.code, 400)
예제 #7
0
 def test_nonexistent(self):
     """If the item doesn't exist, it will be reported in the body
     of the response.
     """
     feed_item = XML_ENTRY % ('foo', 1)
     feed = XML_WRAPPER % feed_item
     request = testing.DummyRequest(body=feed,
                                    content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(
         response.body,
         'Removed 0 items. 1 items could not be found for deletion: 1')
     self.assertEquals(response.code, 200)
예제 #8
0
 def test_nonexistent(self):
     """If the item doesn't exist, it will be reported in the body
     of the response.
     """
     feed_item = XML_ENTRY % ('foo', 1)
     feed = XML_WRAPPER % feed_item
     request = testing.DummyRequest(
         body=feed,
         content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(
         response.body,
         'Removed 0 items. 1 items could not be found for deletion: 1'
     )
     self.assertEquals(response.code, 200)
예제 #9
0
 def test_removal(self):
     """When an item is present in the feed, it will be deleted
     """
     obj = SharedItem()
     obj.__name__ = 'item_uid'
     obj.__parent__ = self.root.shared
     self.root.shared['item_uid'] = obj
     feed_item = XML_ENTRY % ('foo', 'item_uid')
     feed = XML_WRAPPER % feed_item
     request = testing.DummyRequest(body=feed,
                                    content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(response.body, 'Removed 1 items.')
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('item_uid', False))
예제 #10
0
 def test_removal(self):
     """When an item is present in the feed, it will be deleted
     """
     obj = SharedItem()
     obj.__name__ = 'item_uid'
     obj.__parent__ = self.root.shared
     self.root.shared['item_uid'] = obj
     feed_item = XML_ENTRY % ('foo', 'item_uid')
     feed = XML_WRAPPER % feed_item
     request = testing.DummyRequest(
         body=feed,
         content_type='application/atom+xml')
     patcher = patch('mysolr.Solr', FakeSolr)
     patcher.start()
     response = delete_items(self.root, request)
     patcher.stop()
     self.assertEquals(response.body, 'Removed 1 items.')
     self.assertEquals(response.code, 200)
     self.failIf(self.root.shared.get('item_uid', False))