Example #1
0
    def test_whenDeleteSuccessfull_thenReturnCollectionDeletedMessage(self, mock_delete, mock_message):
        colResponse = MagicMock(spec=Response, status_code=204)
        mock_delete.return_value = colResponse
        form = CollectionDeleteForm()
        collectionDeleteView = views.CollectionDeleteView()
        collectionDeleteView.request = FakeRequest()
        collectionDeleteView.kwargs = {
            'org': 'testOrgId',
        }

        result = collectionDeleteView.form_valid(form)
        mock_message.add_message.asser_called_with("error", "Error")
Example #2
0
 def test_getContextForCol_contextForCollectionReceived(self, mock_get):
     colResponse = MagicMock(spec=Response)
     colResponse.json.return_value = "testCollection"
     mock_get.return_value = colResponse
     collectionDeleteView = views.CollectionDeleteView()
     collectionDeleteView.request = FakeRequest()
     collectionDeleteView.collection = {'id': 'mycolid'}
     collectionDeleteView.kwargs = {
         'collection_id': 'testColId',
     }
     context = collectionDeleteView.get_context_data();
     self.assertEquals(context['collection'], 'testCollection')