Changeset 5174
- Timestamp:
- 05/08/07 12:46:05 (1 year ago)
- Files:
-
- django/branches/boulder-oracle-sprint/AUTHORS (modified) (4 diffs)
- django/branches/boulder-oracle-sprint/django/conf/locale/de/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/boulder-oracle-sprint/django/conf/locale/de/LC_MESSAGES/django.po (modified) (6 diffs)
- django/branches/boulder-oracle-sprint/django/contrib/admin/templatetags/log.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/contrib/contenttypes/generic.py (copied) (copied from django/trunk/django/contrib/contenttypes/generic.py)
- django/branches/boulder-oracle-sprint/django/core/cache/backends/base.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/core/management.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/db/models/base.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/db/models/fields/generic.py (deleted)
- django/branches/boulder-oracle-sprint/django/db/models/__init__.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/db/models/query.py (modified) (3 diffs)
- django/branches/boulder-oracle-sprint/django/template/__init__.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/test/testcases.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/test/utils.py (modified) (3 diffs)
- django/branches/boulder-oracle-sprint/docs/contributing.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/i18n.txt (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/docs/model-api.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/serialization.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/sitemaps.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/templates_python.txt (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/docs/testing.txt (modified) (8 diffs)
- django/branches/boulder-oracle-sprint/tests/modeltests/generic_relations/models.py (modified) (4 diffs)
- django/branches/boulder-oracle-sprint/tests/modeltests/test_client/models.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/tests/modeltests/test_client/urls.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/tests/modeltests/test_client/views.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/tests/regressiontests/cache/tests.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py (modified) (3 diffs)
- django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/AUTHORS
r5135 r5174 44 44 adurdin@gmail.com 45 45 alang@bright-green.com 46 Marty Alchin <gulopine@gamemusic.org> 46 47 Daniel Alves Barbosa de Oliveira Vaz <danielvaz@gmail.com> 47 48 Andreas … … 50 51 ant9000@netwise.it 51 52 David Ascher <http://ascher.ca/> 53 david@kazserve.org 52 54 Arthur <avandorp@gmail.com> 53 55 axiak@mit.edu … … 69 71 ChaosKCW 70 72 ivan.chelubeev@gmail.com 73 Bryan Chow <bryan at verdjn dot com> 71 74 Ian Clelland <clelland@gmail.com> 72 75 crankycoder@gmail.com … … 146 149 Waylan Limberg <waylan@gmail.com> 147 150 limodou 148 mattmcc151 Matt McClanahan <http://mmcc.cx/> 149 152 Martin Maney <http://www.chipy.org/Martin_Maney> 150 153 masonsimon+django@gmail.com django/branches/boulder-oracle-sprint/django/conf/locale/de/LC_MESSAGES/django.po
r5128 r5174 368 368 #: contrib/admin/templates/admin/base_site.html:4 369 369 msgid "Django site admin" 370 msgstr "Django Systemverwaltung"370 msgstr "Django-Systemverwaltung" 371 371 372 372 #: contrib/admin/templates/admin/base_site.html:7 373 373 msgid "Django administration" 374 msgstr "Django Verwaltung"374 msgstr "Django-Verwaltung" 375 375 376 376 #: contrib/admin/templates/admin/change_form.html:15 … … 386 386 #: contrib/admin/templates/admin/change_form.html:22 387 387 msgid "View on site" 388 msgstr "Im Web Anzeigen"388 msgstr "Im Web anzeigen" 389 389 390 390 #: contrib/admin/templates/admin/change_form.html:32 … … 615 615 msgstr "" 616 616 "\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" 618 618 "Browser-Werkzeugleiste gezogen werden, oder mittels rechter Maustaste in " 619 619 "die\n" … … 999 999 #: contrib/admin/views/main.py:223 1000 1000 msgid "Site administration" 1001 msgstr "Website Verwaltung"1001 msgstr "Website-Verwaltung" 1002 1002 1003 1003 #: contrib/admin/views/main.py:271 contrib/admin/views/main.py:356 … … 1024 1024 #, python-format 1025 1025 msgid "Changed %s." 1026 msgstr "%s geändert "1026 msgstr "%s geändert." 1027 1027 1028 1028 #: contrib/admin/views/main.py:339 … … 1491 1491 "This rating is required because you've entered at least one other rating." 1492 1492 msgstr "" 1493 "Diese Abstimmung ist zwingend erforderlich, da Duan mindestens einer "1494 "weiteren Abstimmung teiln immst."1493 "Diese Abstimmung ist zwingend erforderlich, da Sie an mindestens einer " 1494 "weiteren Abstimmung teilnehmen." 1495 1495 1496 1496 #: contrib/comments/views/comments.py:111 django/branches/boulder-oracle-sprint/django/contrib/admin/templatetags/log.py
r2809 r5174 12 12 13 13 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] 17 20 return '' 18 21 django/branches/boulder-oracle-sprint/django/core/cache/backends/base.py
r4279 r5174 55 55 """ 56 56 return self.get(key) is not None 57 58 __contains__ = has_key 59 django/branches/boulder-oracle-sprint/django/core/management.py
r5136 r5174 261 261 def _get_many_to_many_sql_for_model(model): 262 262 from django.db import backend, get_creation_module 263 from django. db.models import GenericRel263 from django.contrib.contenttypes import generic 264 264 265 265 data_types = get_creation_module().DATA_TYPES … … 268 268 final_output = [] 269 269 for f in opts.many_to_many: 270 if not isinstance(f.rel, GenericRel):270 if not isinstance(f.rel, generic.GenericRel): 271 271 tablespace = f.db_tablespace or opts.db_tablespace 272 272 if tablespace and backend.supports_tablespaces and backend.autoindexes_primary_keys: django/branches/boulder-oracle-sprint/django/db/models/base.py
r4906 r5174 43 43 new_class._meta.parents.extend(base._meta.parents) 44 44 45 model_module = sys.modules[new_class.__module__]46 45 47 46 if getattr(new_class._meta, 'app_label', None) is None: 48 47 # Figure out the app_label by looking one level up. 49 48 # For 'django.contrib.sites.models', this would be 'sites'. 49 model_module = sys.modules[new_class.__module__] 50 50 new_class._meta.app_label = model_module.__name__.split('.')[-2] 51 51 django/branches/boulder-oracle-sprint/django/db/models/__init__.py
r4990 r5174 9 9 from django.db.models.fields import * 10 10 from django.db.models.fields.related import ForeignKey, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, TABULAR, STACKED 11 from django.db.models.fields.generic import GenericRelation, GenericRel, GenericForeignKey12 11 from django.db.models import signals 13 12 from django.utils.functional import curry django/branches/boulder-oracle-sprint/django/db/models/query.py
r5157 r5174 1 1 from django.db import backend, connection, transaction 2 2 from django.db.models.fields import DateField, FieldDoesNotExist 3 from django.db.models.fields.generic import GenericRelation 4 from django.db.models import signals 3 from django.db.models import signals, loading 5 4 from django.dispatch import dispatcher 6 5 from django.utils.datastructures import SortedDict 7 from django.con f import settings6 from django.contrib.contenttypes import generic 8 7 import datetime 9 8 import operator … … 1092 1091 pk_list = [pk for pk,instance in seen_objs[cls]] 1093 1092 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): 1095 1094 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 1096 1095 cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \ … … 1100 1099 pk_list[offset:offset+GET_ITERATOR_CHUNK_SIZE]) 1101 1100 for f in cls._meta.many_to_many: 1102 if isinstance(f, GenericRelation):1101 if isinstance(f, generic.GenericRelation): 1103 1102 from django.contrib.contenttypes.models import ContentType 1104 1103 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 99 99 # global list of libraries to load by default for a new parser 100 100 builtins = [] 101 102 # True if TEMPLATE_STRING_IF_INVALID contains a format string (%s). None means 103 # uninitialised. 104 invalid_var_format_string = None 101 105 102 106 class TemplateSyntaxError(Exception): … … 576 580 else: 577 581 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 578 587 return settings.TEMPLATE_STRING_IF_INVALID 579 588 else: django/branches/boulder-oracle-sprint/django/test/testcases.py
r5157 r5174 2 2 from urlparse import urlparse 3 3 from django.db import transaction 4 from django.core import management 4 from django.core import management, mail 5 5 from django.db.models import get_apps 6 6 from django.test.client import Client … … 34 34 35 35 class 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: 39 38 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 40 43 """ 41 44 management.flush(verbosity=0, interactive=False) 42 45 if hasattr(self, 'fixtures'): 43 46 management.load_data(self.fixtures, verbosity=0) 44 47 mail.outbox = [] 48 45 49 def run(self, result=None): 46 """Wrapper around default run method so that user-defined Test Cases47 automatically call install_fixtures without having to include a call to48 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(). 49 53 50 54 """ 51 55 self.client = Client() 52 self. install_fixtures()56 self._pre_setup() 53 57 super(TestCase, self).run(result) 54 58 django/branches/boulder-oracle-sprint/django/test/utils.py
r4695 r5174 2 2 from django.conf import settings 3 3 from django.db import connection, backend, get_creation_module 4 from django.core import management 4 from django.core import management, mail 5 5 from django.dispatch import dispatcher 6 6 from django.test import signals … … 19 19 return self.nodelist.render(context) 20 20 21 class 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 21 39 def setup_test_environment(): 22 40 """Perform any global pre-test setup. This involves: 23 41 24 42 - Installing the instrumented test renderer 43 - Diverting the email sending functions to a test buffer 25 44 26 45 """ … … 28 47 Template.render = instrumented_test_render 29 48 49 mail.original_SMTPConnection = mail.SMTPConnection 50 mail.SMTPConnection = TestSMTPConnection 51 52 mail.outbox = [] 53 30 54 def teardown_test_environment(): 31 55 """Perform any global post-test teardown. This involves: 32 56 33 57 - Restoring the original test renderer 58 - Restoring the email sending functions 34 59 35 60 """ 36 61 Template.render = Template.original_render 37 62 del Template.original_render 63 64 mail.SMTPConnection = mail.original_SMTPConnection 65 del mail.original_SMTPConnection 66 67 del mail.outbox 38 68 39 69 def _set_autocommit(connection): django/branches/boulder-oracle-sprint/docs/contributing.txt
r4755 r5174 397 397 398 398 Yes, 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. 399 info -- the ``DATABASE_NAME`` (required, but will be ignored), 400 ``DATABASE_ENGINE``, ``DATABASE_USER`` and ``DATABASE_PASSWORD`` settings. You 401 will also need a ``ROOT_URLCONF`` setting (its value is ignored; it just needs 402 to be present) and a ``SITE_ID`` setting (any integer value will do) in order 403 for all the tests to pass. 403 404 404 405 The unit tests will not touch your existing databases; they create a new django/branches/boulder-oracle-sprint/docs/i18n.txt
r5079 r5174 311 311 ...where ``de`` is the language code for the message file you want to create. 312 312 The 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. 314 314 315 315 The script should be run from one of three places: … … 464 464 465 465 * In each of these places, the language preference is expected to be in the 466 standard language format, as a string. For example, Brazilian is467 ``pt-br``.466 standard language format, as a string. For example, Brazilian Portugese 467 is ``pt-br``. 468 468 * If a base language is available but the sublanguage specified is not, 469 469 Django uses the base language. For example, if a user specifies ``de-at`` django/branches/boulder-oracle-sprint/docs/model-api.txt
r5079 r5174 460 460 ~~~~~~~~~ 461 461 462 If ``True``, the field is allowed to be blank. 462 If ``True``, the field is allowed to be blank. Default is ``False``. 463 463 464 464 Note that this is different than ``null``. ``null`` is purely django/branches/boulder-oracle-sprint/docs/serialization.txt
r5079 r5174 110 110 For example:: 111 111 112 json_serializer = serializers.get_serializer("json") 112 json_serializer = serializers.get_serializer("json")() 113 113 json_serializer.serialize(queryset, ensure_ascii=False, stream=response) 114 114 django/branches/boulder-oracle-sprint/docs/sitemaps.txt
r4456 r5174 2 2 The sitemap framework 3 3 ===================== 4 5 **New in Django development version**.6 4 7 5 Django comes with a high-level sitemap-generating framework that makes django/branches/boulder-oracle-sprint/docs/templates_python.txt
r5148 r5174 213 213 applied to invalid variables within these template tags. 214 214 215 If ``TEMPLATE_STRING_IF_INVALID`` contains a ``'%s'``, the format marker will 216 be replaced with the name of the invalid variable. 217 215 218 .. admonition:: For debug purposes only! 216 219 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'. 219 222 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 222 225 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 224 227 problems with these templates and sites. 225 228 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 228 231 once debugging is complete. 229 232 230 233 Playing with Context objects 231 234 ---------------------------- … … 867 870 actual_date = resolve_variable(self.date_to_be_formatted, context) 868 871 return actual_date.strftime(self.format_string) 869 except VariableDoesNotExist:872 except template.VariableDoesNotExist: 870 873 return '' 871 874 django/branches/boulder-oracle-sprint/docs/testing.txt
r5157 r5174 178 178 * `Test Client`_ 179 179 * `TestCase`_ 180 * `Email services`_ 180 181 181 182 Test Client … … 258 259 259 260 ``login(**credentials)`` 260 ** New in Django development version**261 **New in Django development version** 261 262 262 263 On a production site, it is likely that some views will be protected from … … 290 291 ~~~~~~~~~~~~~~~~~ 291 292 292 The ``get()`` , ``post()`` and ``login()`` methods all return a Response293 object. This Response object has the following properties that can be used 294 for testingpurposes:293 The ``get()`` and ``post()`` methods both return a Response object. This 294 Response object has the following properties that can be used for testing 295 purposes: 295 296 296 297 =============== ========================================================== … … 397 398 Default Test Client 398 399 ~~~~~~~~~~~~~~~~~~~ 399 ** New in Django development version**400 **New in Django development version** 400 401 401 402 Every test case in a ``django.test.TestCase`` instance has access to an … … 454 455 another test, or the order of test execution. 455 456 457 Emptying the test outbox 458 ~~~~~~~~~~~~~~~~~~~~~~~~ 459 **New in Django development version** 460 461 At the start of each test case, in addition to installing fixtures, 462 Django clears the contents of the test email outbox. 463 464 For more detail on email services during tests, see `Email services`_. 465 456 466 Assertions 457 467 ~~~~~~~~~~ 458 ** New in Django development version**468 **New in Django development version** 459 469 460 470 Normal Python unit tests have a wide range of assertions, such as … … 469 479 470 480 ``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`` 477 487 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 482 492 ``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 484 494 the response. 485 495 486 496 ``assertRedirects(response, expected_path)`` 487 497 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. 489 499 490 500 ``assertTemplateUsed(response, template_name)`` 491 501 Assert that the template with the given name was used in rendering the 492 502 response. 493 494 503 504 Email services 505 -------------- 506 **New in Django development version** 507 508 If your view makes use of the `Django email services`_, you don't really 509 want email to be sent every time you run a test using that view. 510 511 When the Django test framework is initialized, it transparently replaces the 512 normal `SMTPConnection`_ class with a dummy implementation that redirects all 513 email to a dummy outbox. This outbox, stored as ``django.core.mail.outbox``, 514 is a simple list of all `EmailMessage`_ instances that have been sent. 515 For example, during test conditions, it would be possible to run the following 516 code:: 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 529 The ``mail.outbox`` object does not exist under normal execution conditions. 530 The outbox is created during test setup, along with the dummy `SMTPConnection`_. 531 When the test framework is torn down, the standard `SMTPConnection`_ class 532 is restored, and the test outbox is destroyed. 533 534 As noted `previously`_, the test outbox is emptied at the start of every 535 test in a Django TestCase. To empty the outbox manually, assign the empty list 536 to 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 495 548 Running tests 496 549 ============= … … 516 569 If you wish to use a name other than the default for the test database, 517 570 you can use the ``TEST_DATABASE_NAME`` setting to provide a name. 571 572 The test database is created by the user in the ``DATABASE_USER`` setting. 573 This user needs to have sufficient privileges to create a new database on the 574 system. 518 575 519 576 Once the test database has been established, Django will run your tests. … … 607 664 ``setup_test_environment()`` 608 665 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. 610 668 611 669 ``teardown_test_environment()`` 612 670 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. 614 672 615 673 ``create_test_db(verbosity=1, autoclobber=False)`` django/branches/boulder-oracle-sprint/tests/modeltests/generic_relations/models.py
r4841 r5174 12 12 from django.db import models 13 13 from django.contrib.contenttypes.models import ContentType 14 from django.contrib.contenttypes import generic 14 15 15 16 class TaggedItem(models.Model): … … 19 20 object_id = models.PositiveIntegerField() 20 21 21 content_object = models.GenericForeignKey()22 content_object = generic.GenericForeignKey() 22 23 23 24 class Meta: … … 31 32 latin_name = models.CharField(maxlength=150) 32 33 33 tags = models.GenericRelation(TaggedItem)34 tags = generic.GenericRelation(TaggedItem) 34 35 35 36 def __str__(self): … … 40 41 is_yucky = models.BooleanField(default=True) 41 42 42 tags = models.GenericRelation(TaggedItem)43 tags = generic.GenericRelation(TaggedItem) 43 44 44 45 def __str__(self): django/branches/boulder-oracle-sprint/tests/modeltests/test_client/models.py
r5157 r5174 21 21 """ 22 22 from django.test import Client, TestCase 23 from django.core import mail 23 24 24 25 class ClientTest(TestCase): … … 233 234 except KeyError: 234 235 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 12 12 (r'^login_protected_view/$', views.login_protected_view), 13 13 (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) 15 17 ) django/branches/boulder-oracle-sprint/tests/modeltests/test_client/views.py
r5157 r5174 1 1 from xml.dom.minidom import parseString 2 from django.core.mail import EmailMessage, SMTPConnection 2 3 from django.template import Context, Template 3 4 from django.http import HttpResponse, HttpResponseRedirect … … 125 126 """A view which just raises an exception, simulating a broken view.""" 126 127 raise KeyError("Oops! Looks like you wrote some bad code.") 128 129 def 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 137 def 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 47 47 self.assertEqual(cache.has_key("goodbye"), False) 48 48 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 49 54 def test_data_types(self): 50 55 # test data types django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py
r4755 r5174 7 7 8 8 from django.db import models 9 from django.contrib.contenttypes import generic 9 10 from django.contrib.contenttypes.models import ContentType 10 11 … … 81 82 object_id = models.PositiveIntegerField() 82 83 83 content_object = models.GenericForeignKey()84 content_object = generic.GenericForeignKey() 84 85 85 86 class Meta: … … 89 90 data = models.CharField(maxlength=30) 90 91 91 tags = models.GenericRelation(Tag)92 tags = generic.GenericRelation(Tag) 92 93 93 94 # The following test classes are all for validation django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py
r5128 r5174 587 587 'invalidstr04': ('{% if var %}Yes{% else %}No{% endif %}', {}, 'No'), 588 588 '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')), 589 591 590 592 ### MULTILINE ############################################################# … … 738 740 # Set TEMPLATE_STRING_IF_INVALID to a known string 739 741 old_invalid = settings.TEMPLATE_STRING_IF_INVALID 742 expected_invalid_str = 'INVALID' 740 743 741 744 for name, vals in tests: … … 745 748 normal_string_result = vals[2][0] 746 749 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 747 754 else: 748 755 normal_string_result = vals[2] … … 755 762 756 763 for invalid_str, result in [('', normal_string_result), 757 ( 'INVALID', invalid_string_result)]:764 (expected_invalid_str, invalid_string_result)]: 758 765 settings.TEMPLATE_STRING_IF_INVALID = invalid_str 759 766 try: … … 769 776 deactivate() 770 777 778 if template.invalid_var_format_string: 779 expected_invalid_str = 'INVALID' 780 template.invalid_var_format_string = False 781 771 782 loader.template_source_loaders = old_template_loaders 772 783 deactivate()
