コード例 #1
0
    def test_always_rollback(self):
        connection = transaction.get_connection()
        with patch.object(connection, 'rollback', wraps=connection.rollback) as mock_rollback:
            with pytest.raises(TestException):
                confirm_email_change(self.request, self.key)

            mock_rollback.assert_called_with()
コード例 #2
0
    def check_confirm_email_change(self, expected_template, expected_context):
        """
        Call `confirm_email_change` and assert that the content was generated as expected

        `expected_template`: The name of the template that should have been used
            to generate the content
        `expected_context`: The context dictionary that should have been used to
            generate the content
        """
        response = confirm_email_change(self.request, self.key)
        assert response.status_code == 200
        assert mock_render_to_response(expected_template, expected_context).content.decode('utf-8') \
               == response.content.decode('utf-8')