Ejemplo n.º 1
0
    def test_post_data_structure_element_contains_module_values(
        self,
        mock_data_structure_element_upsert,
        mock_data_structure_element_get_by_id,
        mock_render_template,
    ):
        mock_module_template = "mock_module_template"
        mock_request = Mock(spec=HttpRequest)
        mock_request.POST = {
            "module_id": str(ObjectId()),
        }
        mock_request.user = create_mock_user("1")

        module_object = ModuleImplementation()

        mock_data_structure_element = _create_mock_data_structure_element()
        mock_data_structure_element_get_by_id.return_value = mock_data_structure_element
        mock_data_structure_element_upsert.return_value = mock_data_structure_element
        mock_render_template.return_value = mock_module_template

        response = module_object.post(mock_request)
        response_html = json.loads(response.content)["html"]

        self.assertEquals(response.status_code, 200)
        self.assertEquals(response_html, mock_module_template)
Ejemplo n.º 2
0
    def test_post_returns_http_response(
        self,
        mock_data_structure_element_upsert,
        mock_data_structure_element_get_by_id,
        mock_render_template,
    ):
        mock_request = Mock(spec=HttpRequest)
        mock_request.POST = {
            "module_id": str(ObjectId()),
        }
        mock_request.user = create_mock_user("1")

        module_object = ModuleImplementation()

        mock_data_structure_element = _create_mock_data_structure_element()
        mock_data_structure_element_get_by_id.return_value = mock_data_structure_element
        mock_data_structure_element_upsert.return_value = mock_data_structure_element
        mock_render_template.return_value = ""

        response = module_object.post(mock_request)

        self.assertTrue(isinstance(response, HttpResponse))