|
1
|
|
|
# coding: utf8 |
|
2
|
|
|
|
|
3
|
|
|
""" |
|
4
|
|
|
This software is licensed under the Apache 2 license, quoted below. |
|
5
|
|
|
|
|
6
|
|
|
Copyright 2015 Crystalnix Limited |
|
7
|
|
|
|
|
8
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|
9
|
|
|
use this file except in compliance with the License. You may obtain a copy of |
|
10
|
|
|
the License at |
|
11
|
|
|
|
|
12
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
|
13
|
|
|
|
|
14
|
|
|
Unless required by applicable law or agreed to in writing, software |
|
15
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
16
|
|
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
17
|
|
|
License for the specific language governing permissions and limitations under |
|
18
|
|
|
the License. |
|
19
|
|
|
""" |
|
20
|
|
|
|
|
21
|
|
|
from django.test import TestCase |
|
22
|
|
|
from django.core.files.uploadedfile import SimpleUploadedFile |
|
23
|
|
|
|
|
24
|
|
|
from omaha.tests.utils import temporary_media_root |
|
25
|
|
|
|
|
26
|
|
|
from feedback.models import Feedback |
|
27
|
|
|
from feedback.serializers import FeedbackSerializer |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
class FeedbackSerializerTest(TestCase): |
|
32
|
|
|
maxDiff = None |
|
33
|
|
|
|
|
34
|
|
|
@temporary_media_root() |
|
35
|
|
|
def test_serializer(self): |
|
36
|
|
|
description = 'Test description' |
|
37
|
|
|
email = '[email protected]' |
|
38
|
|
|
page_url = 'http://google.com/' |
|
39
|
|
|
feedback_data = { |
|
40
|
|
|
'web_data': { |
|
41
|
|
|
'url': page_url |
|
42
|
|
|
}, |
|
43
|
|
|
'common_data': { |
|
44
|
|
|
'description': description, |
|
45
|
|
|
'user_email': email, |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
feedback = Feedback.objects.create( |
|
50
|
|
|
description=description, |
|
51
|
|
|
email=email, |
|
52
|
|
|
page_url=page_url, |
|
53
|
|
|
screenshot=SimpleUploadedFile('./screenshot.png', b''), |
|
54
|
|
|
blackbox=SimpleUploadedFile('./blackbox.tar', b''), |
|
55
|
|
|
system_logs=SimpleUploadedFile('./sys_logs.zip', b''), |
|
56
|
|
|
attached_file=SimpleUploadedFile('./attach.zip', b''), |
|
57
|
|
|
feedback_data=feedback_data, |
|
58
|
|
|
) |
|
59
|
|
|
|
|
60
|
|
|
self.assertDictEqual(FeedbackSerializer(feedback).data, |
|
61
|
|
|
dict(id=feedback.id, |
|
62
|
|
|
created=feedback.created.strftime('%Y-%m-%dT%H:%M:%S.%fZ'), |
|
63
|
|
|
modified=feedback.modified.strftime('%Y-%m-%dT%H:%M:%S.%fZ'), |
|
64
|
|
|
screenshot=feedback.screenshot.url, |
|
65
|
|
|
blackbox=feedback.blackbox.url, |
|
66
|
|
|
system_logs=feedback.system_logs.url, |
|
67
|
|
|
attached_file=feedback.attached_file.url, |
|
68
|
|
|
feedback_data=feedback.feedback_data, |
|
69
|
|
|
)) |
|
70
|
|
|
|