def test_getContextForColVersion_contextForCollectionVersionReceived(self, mock_get): colResponse = MagicMock(spec=Response) colResponse.json.return_value = "testCollection" mock_get.return_value = colResponse collectionVersionNewView = views.CollectionVersionsNewView() collectionVersionNewView.request = FakeRequest() collectionVersionNewView.collection = {'id': 'mycolid'} collectionVersionNewView.kwargs = { 'collection_id': 'testColId', } context = collectionVersionNewView.get_context_data() self.assertEquals(context['collection'], 'testCollection')
def test_whenDeleteSuccessfull_thenReturnCollectionDeletedMessage(self, mock_create_version, mock_message): colResponse = MagicMock(spec=Response, status_code=204) mock_create_version.return_value = colResponse form_data = { 'id': 'testv1', 'description': 'testdescription', } form = CollectionVersionAddForm(form_data) form.full_clean() collectionNewVserionView = views.CollectionVersionsNewView() collectionNewVserionView.request = FakeRequest() collectionNewVserionView.kwargs = { 'org': 'testOrgId', } result = collectionNewVserionView.form_valid(form) mock_message.add_message.asser_called_with("error", "Error")