# coding: utf-8
#
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__author__ = 'Sean Lip'

import datetime

from core.platform import models
(email_models,) = models.Registry.import_models([models.NAMES.email])
import test_utils


class SentEmailModelUnitTests(test_utils.GenericTestBase):
    """Test the SentEmailModel class."""

    def test_sent_email_model_instances_are_read_only(self):
        email_models.SentEmailModel.create(
            'recipient_id', 'recipient@email.com', 'sender_id',
            'sender@email.com', email_models.INTENT_SIGNUP,
            'Email Subject', 'Email Body', datetime.datetime.utcnow())

        model = email_models.SentEmailModel.get_all().fetch()[0]
        model.recipient_id = 'new_recipient_id'
        with self.assertRaises(Exception):
            model.put()
