Django

Code

Changeset 5174

Show
Ignore:
Timestamp:
05/08/07 12:46:05 (1 year ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Merged to [5173]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/AUTHORS

    r5135 r5174  
    4444    adurdin@gmail.com 
    4545    alang@bright-green.com 
     46    Marty Alchin <gulopine@gamemusic.org> 
    4647    Daniel Alves Barbosa de Oliveira Vaz <danielvaz@gmail.com> 
    4748    Andreas 
     
    5051    ant9000@netwise.it 
    5152    David Ascher <http://ascher.ca/> 
     53    david@kazserve.org 
    5254    Arthur <avandorp@gmail.com> 
    5355    axiak@mit.edu 
     
    6971    ChaosKCW 
    7072    ivan.chelubeev@gmail.com 
     73    Bryan Chow <bryan at verdjn dot com> 
    7174    Ian Clelland <clelland@gmail.com> 
    7275    crankycoder@gmail.com 
     
    146149    Waylan Limberg <waylan@gmail.com> 
    147150    limodou 
    148     mattmcc 
     151    Matt McClanahan <http://mmcc.cx/> 
    149152    Martin Maney <http://www.chipy.org/Martin_Maney> 
    150153    masonsimon+django@gmail.com 
  • django/branches/boulder-oracle-sprint/django/conf/locale/de/LC_MESSAGES/django.po

    r5128 r5174  
    368368#: contrib/admin/templates/admin/base_site.html:4 
    369369msgid "Django site admin" 
    370 msgstr "Django Systemverwaltung" 
     370msgstr "Django-Systemverwaltung" 
    371371 
    372372#: contrib/admin/templates/admin/base_site.html:7 
    373373msgid "Django administration" 
    374 msgstr "Django Verwaltung" 
     374msgstr "Django-Verwaltung" 
    375375 
    376376#: contrib/admin/templates/admin/change_form.html:15 
     
    386386#: contrib/admin/templates/admin/change_form.html:22 
    387387msgid "View on site" 
    388 msgstr "Im Web Anzeigen" 
     388msgstr "Im Web anzeigen" 
    389389 
    390390#: contrib/admin/templates/admin/change_form.html:32 
     
    615615msgstr "" 
    616616"\n" 
    617 "<p class=\"help\">Um Bookmarklets zu installieren müssen diese Links in die\n" 
     617"<p class=\"help\">Um Bookmarklets zu installieren, müssen diese Links in die\n" 
    618618"Browser-Werkzeugleiste gezogen werden, oder mittels rechter Maustaste in " 
    619619"die\n" 
     
    999999#: contrib/admin/views/main.py:223 
    10001000msgid "Site administration" 
    1001 msgstr "Website Verwaltung" 
     1001msgstr "Website-Verwaltung" 
    10021002 
    10031003#: contrib/admin/views/main.py:271 contrib/admin/views/main.py:356 
     
    10241024#, python-format 
    10251025msgid "Changed %s." 
    1026 msgstr "%s geändert
     1026msgstr "%s geändert.
    10271027 
    10281028#: contrib/admin/views/main.py:339 
     
    14911491"This rating is required because you've entered at least one other rating." 
    14921492msgstr "" 
    1493 "Diese Abstimmung ist zwingend erforderlich, da Du an mindestens einer " 
    1494 "weiteren Abstimmung teilnimmst." 
     1493"Diese Abstimmung ist zwingend erforderlich, da Sie an mindestens einer " 
     1494"weiteren Abstimmung teilnehmen." 
    14951495 
    14961496#: contrib/comments/views/comments.py:111 
  • django/branches/boulder-oracle-sprint/django/contrib/admin/templatetags/log.py

    r2809 r5174  
    1212 
    1313    def render(self, context): 
    14         if self.user is not None and not self.user.isdigit(): 
    15             self.user = context[self.user].id 
    16         context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit] 
     14        if self.user is None: 
     15            context[self.varname] = LogEntry.objects.all().select_related()[:self.limit] 
     16        else: 
     17            if not self.user.isdigit(): 
     18                self.user = context[self.user].id 
     19            context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit] 
    1720        return '' 
    1821 
  • django/branches/boulder-oracle-sprint/django/core/cache/backends/base.py

    r4279 r5174  
    5555        """ 
    5656        return self.get(key) is not None 
     57 
     58    __contains__ = has_key 
     59 
  • django/branches/boulder-oracle-sprint/django/core/management.py

    r5136 r5174  
    261261def _get_many_to_many_sql_for_model(model): 
    262262    from django.db import backend, get_creation_module 
    263     from django.db.models import GenericRel 
     263    from django.contrib.contenttypes import generic 
    264264 
    265265    data_types = get_creation_module().DATA_TYPES 
     
    268268    final_output = [] 
    269269    for f in opts.many_to_many: 
    270         if not isinstance(f.rel, GenericRel): 
     270        if not isinstance(f.rel, generic.GenericRel): 
    271271            tablespace = f.db_tablespace or opts.db_tablespace 
    272272            if tablespace and backend.supports_tablespaces and backend.autoindexes_primary_keys: 
  • django/branches/boulder-oracle-sprint/django/db/models/base.py

    r4906 r5174  
    4343                new_class._meta.parents.extend(base._meta.parents) 
    4444 
    45         model_module = sys.modules[new_class.__module__] 
    4645 
    4746        if getattr(new_class._meta, 'app_label', None) is None: 
    4847            # Figure out the app_label by looking one level up. 
    4948            # For 'django.contrib.sites.models', this would be 'sites'. 
     49            model_module = sys.modules[new_class.__module__] 
    5050            new_class._meta.app_label = model_module.__name__.split('.')[-2] 
    5151 
  • django/branches/boulder-oracle-sprint/django/db/models/__init__.py

    r4990 r5174  
    99from django.db.models.fields import * 
    1010from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, TABULAR, STACKED 
    11 from django.db.models.fields.generic import GenericRelation, GenericRel, GenericForeignKey 
    1211from django.db.models import signals 
    1312from django.utils.functional import curry 
  • django/branches/boulder-oracle-sprint/django/db/models/query.py

    r5157 r5174  
    11from django.db import backend, connection, transaction 
    22from django.db.models.fields import DateField, FieldDoesNotExist 
    3 from django.db.models.fields.generic import GenericRelation 
    4 from django.db.models import signals 
     3from django.db.models import signals, loading 
    54from django.dispatch import dispatcher 
    65from django.utils.datastructures import SortedDict 
    7 from django.conf import settings 
     6from django.contrib.contenttypes import generic 
    87import datetime 
    98import operator 
     
    10921091        pk_list = [pk for pk,instance in seen_objs[cls]] 
    10931092        for related in cls._meta.get_all_related_many_to_many_objects(): 
    1094             if not isinstance(related.field, GenericRelation): 
     1093            if not isinstance(related.field, generic.GenericRelation): 
    10951094                for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 
    10961095                    cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \ 
     
    11001099                        pk_list[offset:offset+GET_ITERATOR_CHUNK_SIZE]) 
    11011100        for f in cls._meta.many_to_many: 
    1102             if isinstance(f, GenericRelation): 
     1101            if isinstance(f, generic.GenericRelation): 
    11031102                from django.contrib.contenttypes.models import ContentType 
    11041103                query_extra = 'AND %s=%%s' % f.rel.to._meta.get_field(f.content_type_field_name).column 
  • django/branches/boulder-oracle-sprint/django/template/__init__.py

    r5128 r5174  
    9999# global list of libraries to load by default for a new parser 
    100100builtins = [] 
     101 
     102# True if TEMPLATE_STRING_IF_INVALID contains a format string (%s). None means 
     103# uninitialised. 
     104invalid_var_format_string = None 
    101105 
    102106class TemplateSyntaxError(Exception): 
     
    576580            else: 
    577581                if settings.TEMPLATE_STRING_IF_INVALID: 
     582                    global invalid_var_format_string 
     583                    if invalid_var_format_string is None: 
     584                        invalid_var_format_string = '%s' in settings.TEMPLATE_STRING_IF_INVALID 
     585                    if invalid_var_format_string: 
     586                        return settings.TEMPLATE_STRING_IF_INVALID % self.var 
    578587                    return settings.TEMPLATE_STRING_IF_INVALID 
    579588                else: 
  • django/branches/boulder-oracle-sprint/django/test/testcases.py

    r5157 r5174  
    22from urlparse import urlparse 
    33from django.db import transaction 
    4 from django.core import management 
     4from django.core import management, mail 
    55from django.db.models import get_apps 
    66from django.test.client import Client 
     
    3434 
    3535class TestCase(unittest.TestCase):     
    36     def install_fixtures(self): 
    37         """If the Test Case class has a 'fixtures' member, clear the database and 
    38         install the named fixtures at the start of each test. 
     36    def _pre_setup(self): 
     37        """Perform any pre-test setup. This includes: 
    3938         
     39            * If the Test Case class has a 'fixtures' member, clearing the  
     40            database and installing the named fixtures at the start of each test. 
     41            * Clearing the mail test outbox. 
     42             
    4043        """ 
    4144        management.flush(verbosity=0, interactive=False) 
    4245        if hasattr(self, 'fixtures'): 
    4346            management.load_data(self.fixtures, verbosity=0) 
    44  
     47        mail.outbox = [] 
     48         
    4549    def run(self, result=None): 
    46         """Wrapper around default run method so that user-defined Test Cases  
    47         automatically call install_fixtures without having to include a call to  
    48         super(). 
     50        """Wrapper around default run method to perform common Django test set up. 
     51        This means that user-defined Test Cases aren't required to include a call  
     52        to super().setUp(). 
    4953         
    5054        """ 
    5155        self.client = Client() 
    52         self.install_fixtures() 
     56        self._pre_setup() 
    5357        super(TestCase, self).run(result) 
    5458 
  • django/branches/boulder-oracle-sprint/django/test/utils.py

    r4695 r5174  
    22from django.conf import settings 
    33from django.db import connection, backend, get_creation_module 
    4 from django.core import management 
     4from django.core import management, mail 
    55from django.dispatch import dispatcher 
    66from django.test import signals 
     
    1919    return self.nodelist.render(context) 
    2020     
     21class TestSMTPConnection(object): 
     22    """A substitute SMTP connection for use during test sessions. 
     23    The test connection stores email messages in a dummy outbox, 
     24    rather than sending them out on the wire. 
     25     
     26    """ 
     27    def __init__(*args, **kwargs): 
     28        pass 
     29    def open(self): 
     30        "Mock the SMTPConnection open() interface" 
     31        pass 
     32    def close(self): 
     33        "Mock the SMTPConnection close() interface" 
     34        pass 
     35    def send_messages(self, messages): 
     36        "Redirect messages to the dummy outbox" 
     37        mail.outbox.extend(messages) 
     38 
    2139def setup_test_environment(): 
    2240    """Perform any global pre-test setup. This involves: 
    2341         
    2442        - Installing the instrumented test renderer 
     43        - Diverting the email sending functions to a test buffer 
    2544         
    2645    """ 
     
    2847    Template.render = instrumented_test_render 
    2948     
     49    mail.original_SMTPConnection = mail.SMTPConnection 
     50    mail.SMTPConnection = TestSMTPConnection 
     51 
     52    mail.outbox = [] 
     53     
    3054def teardown_test_environment(): 
    3155    """Perform any global post-test teardown. This involves: 
    3256 
    3357        - Restoring the original test renderer 
     58        - Restoring the email sending functions 
    3459         
    3560    """ 
    3661    Template.render = Template.original_render 
    3762    del Template.original_render 
     63     
     64    mail.SMTPConnection = mail.original_SMTPConnection 
     65    del mail.original_SMTPConnection 
     66     
     67    del mail.outbox 
    3868     
    3969def _set_autocommit(connection): 
  • django/branches/boulder-oracle-sprint/docs/contributing.txt

    r4755 r5174  
    397397 
    398398Yes, the unit tests need a settings module, but only for database connection 
    399 info -- the ``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD``. 
    400 You will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just 
    401 needs to be present) and a ``SITE_ID`` setting (any integer value will do) in 
    402 order for all the tests to pass. 
     399info -- the ``DATABASE_NAME`` (required, but will be ignored), 
     400``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD`` settings. You 
     401will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just needs 
     402to be present) and a ``SITE_ID`` setting (any integer value will do) in order 
     403for all the tests to pass. 
    403404 
    404405The unit tests will not touch your existing databases; they create a new 
  • django/branches/boulder-oracle-sprint/docs/i18n.txt

    r5079 r5174  
    311311...where ``de`` is the language code for the message file you want to create. 
    312312The language code, in this case, is in locale format. For example, it's 
    313 ``pt_BR`` for Brazilian and ``de_AT`` for Austrian German. 
     313``pt_BR`` for Brazilian Portugese and ``de_AT`` for Austrian German. 
    314314 
    315315The script should be run from one of three places: 
     
    464464 
    465465    * In each of these places, the language preference is expected to be in the 
    466       standard language format, as a string. For example, Brazilian is 
    467       ``pt-br``. 
     466      standard language format, as a string. For example, Brazilian Portugese 
     467      is ``pt-br``. 
    468468    * If a base language is available but the sublanguage specified is not, 
    469469      Django uses the base language. For example, if a user specifies ``de-at`` 
  • django/branches/boulder-oracle-sprint/docs/model-api.txt

    r5079 r5174  
    460460~~~~~~~~~ 
    461461 
    462 If ``True``, the field is allowed to be blank. 
     462If ``True``, the field is allowed to be blank. Default is ``False``. 
    463463 
    464464Note that this is different than ``null``. ``null`` is purely 
  • django/branches/boulder-oracle-sprint/docs/serialization.txt

    r5079 r5174  
    110110For example:: 
    111111 
    112     json_serializer = serializers.get_serializer("json") 
     112    json_serializer = serializers.get_serializer("json")() 
    113113    json_serializer.serialize(queryset, ensure_ascii=False, stream=response) 
    114114 
  • django/branches/boulder-oracle-sprint/docs/sitemaps.txt

    r4456 r5174  
    22The sitemap framework 
    33===================== 
    4  
    5 **New in Django development version**. 
    64 
    75Django comes with a high-level sitemap-generating framework that makes 
  • django/branches/boulder-oracle-sprint/docs/templates_python.txt

    r5148 r5174  
    213213applied to invalid variables within these template tags. 
    214214 
     215If ``TEMPLATE_STRING_IF_INVALID`` contains a ``'%s'``, the format marker will 
     216be replaced with the name of the invalid variable. 
     217 
    215218.. admonition:: For debug purposes only! 
    216219 
    217     While ``TEMPLATE_STRING_IF_INVALID`` can be a useful debugging tool,  
    218     it is a bad idea to turn it on as a 'development default'.  
     220    While ``TEMPLATE_STRING_IF_INVALID`` can be a useful debugging tool, 
     221    it is a bad idea to turn it on as a 'development default'. 
    219222     
    220     Many templates, including those in the Admin site, rely upon the  
    221     silence of the template system when a non-existent variable is  
     223    Many templates, including those in the Admin site, rely upon the 
     224    silence of the template system when a non-existent variable is 
    222225    encountered. If you assign a value other than ``''`` to 
    223     ``TEMPLATE_STRING_IF_INVALID``, you will experience rendering  
     226    ``TEMPLATE_STRING_IF_INVALID``, you will experience rendering 
    224227    problems with these templates and sites. 
    225228     
    226     Generally, ``TEMPLATE_STRING_IF_INVALID`` should only be enabled  
    227     in order to debug a specific template problem, then cleared  
     229    Generally, ``TEMPLATE_STRING_IF_INVALID`` should only be enabled 
     230    in order to debug a specific template problem, then cleared 
    228231    once debugging is complete. 
    229          
     232 
    230233Playing with Context objects 
    231234---------------------------- 
     
    867870                actual_date = resolve_variable(self.date_to_be_formatted, context) 
    868871                return actual_date.strftime(self.format_string) 
    869             except VariableDoesNotExist: 
     872            except template.VariableDoesNotExist: 
    870873                return '' 
    871874 
  • django/branches/boulder-oracle-sprint/docs/testing.txt

    r5157 r5174  
    178178* `Test Client`_ 
    179179* `TestCase`_ 
     180* `Email services`_ 
    180181 
    181182Test Client 
     
    258259 
    259260``login(**credentials)`` 
    260     ** New in Django development version ** 
     261    **New in Django development version** 
    261262 
    262263    On a production site, it is likely that some views will be protected from 
     
    290291~~~~~~~~~~~~~~~~~ 
    291292 
    292 The ``get()``, ``post()`` and ``login()`` methods all return a Response 
    293 object. This Response object has the following properties that can be used 
    294 for testing purposes: 
     293The ``get()`` and ``post()`` methods both return a Response object. This 
     294Response object has the following properties that can be used for testing 
     295purposes: 
    295296 
    296297    ===============  ========================================================== 
     
    397398Default Test Client 
    398399~~~~~~~~~~~~~~~~~~~ 
    399 ** New in Django development version ** 
     400**New in Django development version** 
    400401 
    401402Every test case in a ``django.test.TestCase`` instance has access to an 
     
    454455another test, or the order of test execution. 
    455456 
     457Emptying the test outbox 
     458~~~~~~~~~~~~~~~~~~~~~~~~ 
     459**New in Django development version** 
     460 
     461At the start of each test case, in addition to installing fixtures, 
     462Django clears the contents of the test email outbox. 
     463 
     464For more detail on email services during tests, see `Email services`_. 
     465 
    456466Assertions 
    457467~~~~~~~~~~ 
    458 ** New in Django development version ** 
     468**New in Django development version** 
    459469 
    460470Normal Python unit tests have a wide range of assertions, such as 
     
    469479 
    470480``assertFormError(response, form, field, errors)`` 
    471     Assert that a field on a form raised the provided list of errors when  
    472     rendered on the form.  
    473      
    474     ``form`` is the name the form object was given in the template context.  
    475      
    476     ``field`` is the name of the field on the form to check. If ``field``  
     481    Assert that a field on a form raised the provided list of errors when 
     482    rendered on the form. 
     483 
     484    ``form`` is the name the form object was given in the template context. 
     485 
     486    ``field`` is the name of the field on the form to check. If ``field`` 
    477487    has a value of ``None``, non-field errors will be checked. 
    478      
    479     ``errors`` is an error string, or a list of error strings, that are  
    480     expected as a result of form validation.     
    481      
     488 
     489    ``errors`` is an error string, or a list of error strings, that are 
     490    expected as a result of form validation. 
     491 
    482492``assertTemplateNotUsed(response, template_name)`` 
    483     Assert that the template with the given name was *not* used in rendering  
     493    Assert that the template with the given name was *not* used in rendering 
    484494    the response. 
    485      
     495 
    486496``assertRedirects(response, expected_path)`` 
    487497    Assert that the response received redirects the browser to the provided 
    488     path, and that the expected_path can be retrieved.  
     498    path, and that the expected_path can be retrieved. 
    489499 
    490500``assertTemplateUsed(response, template_name)`` 
    491501    Assert that the template with the given name was used in rendering the 
    492502    response. 
    493      
    494      
     503 
     504Email services 
     505-------------- 
     506**New in Django development version** 
     507 
     508If your view makes use of the `Django email services`_, you don't really 
     509want email to be sent every time you run a test using that view. 
     510 
     511When the Django test framework is initialized, it transparently replaces the 
     512normal `SMTPConnection`_ class with a dummy implementation that redirects all 
     513email to a dummy outbox. This outbox, stored as ``django.core.mail.outbox``, 
     514is a simple list of all `EmailMessage`_ instances that have been sent. 
     515For example, during test conditions, it would be possible to run the following 
     516code:: 
     517 
     518    from django.core import mail 
     519 
     520    # Send message 
     521    mail.send_mail('Subject here', 'Here is the message.', 'from@example.com', 
     522        ['to@example.com'], fail_silently=False) 
     523 
     524    # One message has been sent 
     525    self.assertEqual(len(mail.outbox), 1) 
     526    # Subject of first message is correct 
     527    self.assertEqual(mail.outbox[0].subject, 'Subject here') 
     528 
     529The ``mail.outbox`` object does not exist under normal execution conditions. 
     530The outbox is created during test setup, along with the dummy `SMTPConnection`_. 
     531When the test framework is torn down, the standard `SMTPConnection`_ class 
     532is restored, and the test outbox is destroyed. 
     533 
     534As noted `previously`_, the test outbox is emptied at the start of every 
     535test in a Django TestCase. To empty the outbox manually, assign the empty list 
     536to mail.outbox:: 
     537 
     538    from django.core import mail 
     539 
     540    # Empty the test outbox 
     541    mail.outbox = [] 
     542 
     543.. _`Django email services`: ../email/ 
     544.. _`SMTPConnection`: ../email/#the-emailmessage-and-smtpconnection-classes 
     545.. _`EmailMessage`: ../email/#the-emailmessage-and-smtpconnection-classes 
     546.. _`previously`: #emptying-the-test-outbox 
     547 
    495548Running tests 
    496549============= 
     
    516569If you wish to use a name other than the default for the test database, 
    517570you can use the ``TEST_DATABASE_NAME`` setting to provide a name. 
     571 
     572The test database is created by the user in the ``DATABASE_USER`` setting. 
     573This user needs to have sufficient privileges to create a new database on the 
     574system. 
    518575 
    519576Once the test database has been established, Django will run your tests. 
     
    607664``setup_test_environment()`` 
    608665    Performs any global pre-test setup, such as the installing the 
    609     instrumentation of the template rendering system. 
     666    instrumentation of the template rendering system and setting up 
     667    the dummy SMTPConnection. 
    610668 
    611669``teardown_test_environment()`` 
    612670    Performs any global post-test teardown, such as removing the instrumentation 
    613     of the template rendering system
     671    of the template rendering system and restoring normal email services
    614672 
    615673``create_test_db(verbosity=1, autoclobber=False)`` 
  • django/branches/boulder-oracle-sprint/tests/modeltests/generic_relations/models.py

    r4841 r5174  
    1212from django.db import models 
    1313from django.contrib.contenttypes.models import ContentType 
     14from django.contrib.contenttypes import generic 
    1415 
    1516class TaggedItem(models.Model): 
     
    1920    object_id = models.PositiveIntegerField() 
    2021     
    21     content_object = models.GenericForeignKey() 
     22    content_object = generic.GenericForeignKey() 
    2223     
    2324    class Meta: 
     
    3132    latin_name = models.CharField(maxlength=150) 
    3233     
    33     tags = models.GenericRelation(TaggedItem) 
     34    tags = generic.GenericRelation(TaggedItem) 
    3435 
    3536    def __str__(self): 
     
    4041    is_yucky = models.BooleanField(default=True) 
    4142     
    42     tags = models.GenericRelation(TaggedItem) 
     43    tags = generic.GenericRelation(TaggedItem) 
    4344     
    4445    def __str__(self): 
  • django/branches/boulder-oracle-sprint/tests/modeltests/test_client/models.py

    r5157 r5174  
    2121""" 
    2222from django.test import Client, TestCase 
     23from django.core import mail 
    2324 
    2425class ClientTest(TestCase): 
     
    233234        except KeyError: 
    234235            pass 
     236     
     237    def test_mail_sending(self): 
     238        "Test that mail is redirected to a dummy outbox during test setup" 
     239         
     240        response = self.client.get('/test_client/mail_sending_view/') 
     241        self.assertEqual(response.status_code, 200) 
     242         
     243        self.assertEqual(len(mail.outbox), 1) 
     244        self.assertEqual(mail.outbox[0].subject, 'Test message') 
     245        self.assertEqual(mail.outbox[0].body, 'This is a test email') 
     246        self.assertEqual(mail.outbox[0].from_email, 'from@example.com')  
     247        self.assertEqual(mail.outbox[0].to[0], 'first@example.com') 
     248        self.assertEqual(mail.outbox[0].to[1], 'second@example.com') 
     249 
     250    def test_mass_mail_sending(self): 
     251        "Test that mass mail is redirected to a dummy outbox during test setup" 
     252         
     253        response = self.client.get('/test_client/mass_mail_sending_view/') 
     254        self.assertEqual(response.status_code, 200) 
     255         
     256        self.assertEqual(len(mail.outbox), 2) 
     257        self.assertEqual(mail.outbox[0].subject, 'First Test message') 
     258        self.assertEqual(mail.outbox[0].body, 'This is the first test email') 
     259        self.assertEqual(mail.outbox[0].from_email, 'from@example.com')  
     260        self.assertEqual(mail.outbox[0].to[0], 'first@example.com') 
     261        self.assertEqual(mail.outbox[0].to[1], 'second@example.com') 
     262 
     263        self.assertEqual(mail.outbox[1].subject, 'Second Test message') 
     264        self.assertEqual(mail.outbox[1].body, 'This is the second test email') 
     265        self.assertEqual(mail.outbox[1].from_email, 'from@example.com')  
     266        self.assertEqual(mail.outbox[1].to[0], 'second@example.com') 
     267        self.assertEqual(mail.outbox[1].to[1], 'third@example.com') 
     268         
  • django/branches/boulder-oracle-sprint/tests/modeltests/test_client/urls.py

    r5157 r5174  
    1212    (r'^login_protected_view/$', views.login_protected_view), 
    1313    (r'^session_view/$', views.session_view), 
    14     (r'^broken_view/$', views.broken_view) 
     14    (r'^broken_view/$', views.broken_view), 
     15    (r'^mail_sending_view/$', views.mail_sending_view), 
     16    (r'^mass_mail_sending_view/$', views.mass_mail_sending_view) 
    1517) 
  • django/branches/boulder-oracle-sprint/tests/modeltests/test_client/views.py

    r5157 r5174  
    11from xml.dom.minidom import parseString 
     2from django.core.mail import EmailMessage, SMTPConnection 
    23from django.template import Context, Template 
    34from django.http import HttpResponse, HttpResponseRedirect 
     
    125126    """A view which just raises an exception, simulating a broken view.""" 
    126127    raise KeyError("Oops! Looks like you wrote some bad code.") 
     128 
     129def mail_sending_view(request): 
     130    EmailMessage( 
     131        "Test message",  
     132        "This is a test email",  
     133        "from@example.com",  
     134        ['first@example.com', 'second@example.com']).send() 
     135    return HttpResponse("Mail sent") 
     136 
     137def mass_mail_sending_view(request): 
     138    m1 = EmailMessage( 
     139        'First Test message',  
     140        'This is the first test email',  
     141        'from@example.com',  
     142        ['first@example.com', 'second@example.com']) 
     143    m2 = EmailMessage( 
     144        'Second Test message',  
     145        'This is the second test email',  
     146        'from@example.com',  
     147        ['second@example.com', 'third@example.com']) 
     148     
     149    c = SMTPConnection() 
     150    c.send_messages([m1,m2]) 
     151     
     152    return HttpResponse("Mail sent") 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/cache/tests.py

    r3661 r5174  
    4747        self.assertEqual(cache.has_key("goodbye"), False) 
    4848 
     49    def test_in(self):  
     50        cache.set("hello", "goodbye")  
     51        self.assertEqual("hello" in cache, True)  
     52        self.assertEqual("goodbye" in cache, False)  
     53 
    4954    def test_data_types(self): 
    5055        # test data types 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py

    r4755 r5174  
    77 
    88from django.db import models 
     9from django.contrib.contenttypes import generic 
    910from django.contrib.contenttypes.models import ContentType 
    1011 
     
    8182    object_id = models.PositiveIntegerField() 
    8283 
    83     content_object = models.GenericForeignKey() 
     84    content_object = generic.GenericForeignKey() 
    8485 
    8586    class Meta: 
     
    8990    data = models.CharField(maxlength=30) 
    9091 
    91     tags = models.GenericRelation(Tag) 
     92    tags = generic.GenericRelation(Tag) 
    9293     
    9394# The following test classes are all for validation 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py

    r5128 r5174  
    587587            'invalidstr04': ('{% if var %}Yes{% else %}No{% endif %}', {}, 'No'), 
    588588            'invalidstr04': ('{% if var|default:"Foo" %}Yes{% else %}No{% endif %}', {}, 'Yes'), 
     589            'invalidstr05': ('{{ var }}', {}, ('', 'INVALID %s', 'var')), 
     590            'invalidstr06': ('{{ var.prop }}', {'var': {}}, ('', 'INVALID %s', 'var.prop')), 
    589591 
    590592            ### MULTILINE ############################################################# 
     
    738740        # Set TEMPLATE_STRING_IF_INVALID to a known string 
    739741        old_invalid = settings.TEMPLATE_STRING_IF_INVALID 
     742        expected_invalid_str = 'INVALID' 
    740743 
    741744        for name, vals in tests: 
     
    745748                normal_string_result = vals[2][0] 
    746749                invalid_string_result = vals[2][1] 
     750                if '%s' in invalid_string_result: 
     751                    expected_invalid_str = 'INVALID %s' 
     752                    invalid_string_result = invalid_string_result % vals[2][2] 
     753                    template.invalid_var_format_string = True 
    747754            else: 
    748755                normal_string_result = vals[2] 
     
    755762 
    756763            for invalid_str, result in [('', normal_string_result), 
    757                                         ('INVALID', invalid_string_result)]: 
     764                                        (expected_invalid_str, invalid_string_result)]: 
    758765                settings.TEMPLATE_STRING_IF_INVALID = invalid_str 
    759766                try: 
     
    769776                deactivate() 
    770777 
     778            if template.invalid_var_format_string: 
     779                expected_invalid_str = 'INVALID' 
     780                template.invalid_var_format_string = False 
     781 
    771782        loader.template_source_loaders = old_template_loaders 
    772783        deactivate()