1
|
|
|
# coding: utf8 |
2
|
|
|
|
3
|
|
|
""" |
4
|
|
|
This software is licensed under the Apache 2 license, quoted below. |
5
|
|
|
|
6
|
|
|
Copyright 2014 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
|
|
|
import os |
22
|
|
|
|
23
|
|
|
from unittest import TestCase |
24
|
|
|
from xmlunittest import XmlTestMixin |
25
|
|
|
|
26
|
|
|
from omaha.tests import fixtures |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
BASE_DIR = os.path.dirname(__file__) |
30
|
|
|
FIXTURES_DIR = os.path.join(BASE_DIR, 'fixtures') |
31
|
|
|
REQUEST_XSD_FILE = os.path.join(BASE_DIR, '..', 'request.xsd') |
32
|
|
|
RESPONSE_XSD_FILE = os.path.join(BASE_DIR, '..', 'response.xsd') |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
class TestRequestScheme(TestCase, XmlTestMixin): |
36
|
|
|
xsd_path = REQUEST_XSD_FILE |
37
|
|
|
|
38
|
|
|
def test_request_update_check(self): |
39
|
|
|
root = self.assertXmlDocument(fixtures.request_update_check) |
40
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
41
|
|
|
|
42
|
|
|
def test_request_event(self): |
43
|
|
|
root = self.assertXmlDocument(fixtures.request_event) |
44
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
45
|
|
|
|
46
|
|
|
def test_request_data(self): |
47
|
|
|
root = self.assertXmlDocument(fixtures.request_data) |
48
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
class TestResponseScheme(TestCase, XmlTestMixin): |
52
|
|
|
xsd_path = RESPONSE_XSD_FILE |
53
|
|
|
|
54
|
|
|
def test_response_update_check_negative(self): |
55
|
|
|
root = self.assertXmlDocument(fixtures.response_update_check_negative) |
56
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
57
|
|
|
|
58
|
|
|
def test_response_update_check_positive(self): |
59
|
|
|
root = self.assertXmlDocument(fixtures.response_update_check_positive) |
60
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
61
|
|
|
|
62
|
|
|
def test_response_event(self): |
63
|
|
|
root = self.assertXmlDocument(fixtures.response_event) |
64
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
65
|
|
|
|
66
|
|
|
def test_response_data(self): |
67
|
|
|
root = self.assertXmlDocument(fixtures.response_data_doc) |
68
|
|
|
self.assertXmlValidXSchema(root, filename=self.xsd_path) |
69
|
|
|
|