allura
修訂 | 76cf08e8741986d04c84d197f7d02396068c6677 (tree) |
---|---|
時間 | 2011-04-29 00:34:05 |
作者 | Dave Brondsema <dbrondsema@geek...> |
Commiter | Wolf |
[#2019] with latest Ming, require ticket_num to always be present
Signed-off-by: Dave Brondsema <dbrondsema@geek.net>
@@ -216,7 +216,7 @@ class Ticket(VersionedArtifact): | ||
216 | 216 | |
217 | 217 | super_id = FieldProperty(schema.ObjectId, if_missing=None) |
218 | 218 | sub_ids = FieldProperty([schema.ObjectId], if_missing=None) |
219 | - ticket_num = FieldProperty(int) | |
219 | + ticket_num = FieldProperty(int, required=True) | |
220 | 220 | summary = FieldProperty(str) |
221 | 221 | description = FieldProperty(str, if_missing='') |
222 | 222 | reported_by_id = ForeignIdProperty(User, if_missing=lambda:c.user._id) |
@@ -1,4 +1,6 @@ | ||
1 | 1 | from ming.orm.ormsession import ThreadLocalORMSession |
2 | +from ming import schema | |
3 | +from nose.tools import raises, assert_raises | |
2 | 4 | |
3 | 5 | from forgetracker.model import Ticket |
4 | 6 | from forgetracker.tests.unit import TrackerTestWithModel |
@@ -7,8 +9,20 @@ from forgetracker.tests.unit import TrackerTestWithModel | ||
7 | 9 | class TestTicketModel(TrackerTestWithModel): |
8 | 10 | def test_that_it_has_ordered_custom_fields(self): |
9 | 11 | custom_fields = dict(my_field='my value') |
10 | - Ticket(summary='my ticket', custom_fields=custom_fields) | |
12 | + Ticket(summary='my ticket', custom_fields=custom_fields, ticket_num=3) | |
11 | 13 | ThreadLocalORMSession.flush_all() |
12 | 14 | ticket = Ticket.query.get(summary='my ticket') |
13 | 15 | assert ticket.custom_fields == dict(my_field='my value') |
14 | 16 | |
17 | + @raises(schema.Invalid) | |
18 | + def test_ticket_num_required(self): | |
19 | + Ticket(summary='my ticket') | |
20 | + | |
21 | + def test_ticket_num_required2(self): | |
22 | + t = Ticket(summary='my ticket', ticket_num=3) | |
23 | + try: | |
24 | + t.ticket_num = None | |
25 | + except schema.Invalid: | |
26 | + pass | |
27 | + else: | |
28 | + raise AssertionError('Expected schema.Invalid to be thrown') |
@@ -23,7 +23,7 @@ Mako==0.3.2 | ||
23 | 23 | Markdown==2.0.3 |
24 | 24 | MarkupSafe==0.11 |
25 | 25 | mercurial==1.4.1 |
26 | -Ming==0.2.1dev-20110412 | |
26 | +Ming==0.2.1dev-20110428 | |
27 | 27 | mock==0.6.0 |
28 | 28 | nose==0.11.3 |
29 | 29 | oauth2==1.2.0 |