Show More
@@ -34,16 +34,15 b' def validate_model(model, expect_content):' | |||
|
34 | 34 | and 'format'. |
|
35 | 35 | """ |
|
36 | 36 | required_keys = { |
|
37 | "name" | |
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 | # Note: This key is specified as just 'modified' in IPEP-27 | |
|
43 | , "last_modified" | |
|
44 | , "mimetype" | |
|
45 |
, |
|
|
46 | , "format" | |
|
37 | "name", | |
|
38 | "path", | |
|
39 | "type", | |
|
40 | "writable", | |
|
41 | "created", | |
|
42 | "last_modified", | |
|
43 | "mimetype", | |
|
44 | "content", | |
|
45 | "format", | |
|
47 | 46 | } |
|
48 | 47 | missing = required_keys - set(model.keys()) |
|
49 | 48 | if missing: |
@@ -52,8 +51,10 b' def validate_model(model, expect_content):' | |||
|
52 | 51 | u"Missing Model Keys: {missing}".format(missing=missing), |
|
53 | 52 | ) |
|
54 | 53 | |
|
55 | # Note: Per IPEP-27, 'mimetype' should be present in this list. | |
|
56 | 54 | maybe_none_keys = ['content', 'format'] |
|
55 | if model['type'] == 'file': | |
|
56 | # mimetype should be populated only for file models | |
|
57 | maybe_none_keys.append('mimetype') | |
|
57 | 58 | if expect_content: |
|
58 | 59 | errors = [key for key in maybe_none_keys if model[key] is None] |
|
59 | 60 | if errors: |
@@ -61,9 +62,12 b' def validate_model(model, expect_content):' | |||
|
61 | 62 | 500, |
|
62 | 63 | u"Keys unexpectedly None: {keys}".format(keys=errors), |
|
63 | 64 | ) |
|
64 | ||
|
65 | 65 | else: |
|
66 | errors = [key for key in maybe_none_keys if model[key] is not None] | |
|
66 | errors = { | |
|
67 | key: model[key] | |
|
68 | for key in maybe_none_keys | |
|
69 | if model[key] is not None | |
|
70 | } | |
|
67 | 71 | if errors: |
|
68 | 72 | raise web.HTTPError( |
|
69 | 73 | 500, |
General Comments 0
You need to be logged in to leave comments.
Login now