Exemple #1
0
    def test_getcontextData_contextDataRecievedWithMappingVersions(
            self, mock_get):
        search_response_mapping = FakeResponse()
        search_response_version = FakeResponse()

        mock_get.side_effect = [
            search_response_mapping, search_response_version
        ]
        mapping = search_response_mapping.json()
        mappingVersion = search_response_version.json()

        mappingVersionsView = views.MappingVersionsView()
        id = 'someID'
        mappingVersionsView.kwargs = {'mapping_id': id}
        mappingVersionsView.request = FakeRequest()
        mappingVersionsView.request.user = MyDict('tempuser', False)

        kwargs = {'mapping_id': id}
        context = mappingVersionsView.get_context_data(**kwargs)

        self.assertEquals(context['kwargs'], kwargs)
        self.assertEquals(context['mapping'], mapping)
        self.assertEquals(context['mapping_versions'], mappingVersion)

        self.assertEquals(context['selected_tab'], 'History')
Exemple #2
0
    def test_getcontextData_getMappingVersionsRaises404Exception_404ErrorReceived(self, mock_get):
        search_response_mapping = FakeResponse()
        search_response_version = FakeResponse()
        search_response_version.status_code = 404

        mock_get.side_effect = [search_response_mapping, search_response_version]

        mappingVersionsView = views.MappingVersionsView()
        id = 'someID'
        mappingVersionsView.kwargs = {'mapping_id': id}
        mappingVersionsView.request = FakeRequest()

        kwargs={'mapping_id': id}
        with self.assertRaises(Http404):
            mappingVersionsView.get_context_data(**kwargs)