TildaClientTest.test_client_methods()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 21
rs 9.3142
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
#
4
# Copyright (c) 2016 dotzero <[email protected]>
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining a copy
7
# of this software and associated documentation files (the "Software"), to deal
8
# in the Software without restriction, including without limitation the rights
9
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
# copies of the Software, and to permit persons to whom the Software is
11
# furnished to do so, subject to the following conditions:
12
#
13
# The above copyright notice and this permission notice shall be included
14
# in all copies or substantial portions of the Software.
15
#
16
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
# SOFTWARE.
23
24
"""This module contains a object that represents Tests for TildaPage"""
25
26
import unittest
27
import sys
28
import tilda
29
from tests.base import BaseTest
30
31
sys.path.append('.')
32
33
34
class TildaClientTest(BaseTest, unittest.TestCase):
35
    """This object represents Tests for Tilda Client."""
36
37
    def test_client_init(self):
38
        """Test Client.__init__() method"""
39
        print('Testing Client.__init__()')
40
41
        self.assertNotEqual(self._client.public, None)
42
        self.assertNotEqual(self._client.secret, None)
43
44
    def test_client_request(self):
45
        """Test Client._request() method"""
46
        print('Testing Client._request()')
47
48
        try:
49
            self._client._request(method='/test/')
50
        except Exception as e:
51
            self.assertTrue(isinstance(e, tilda.TildaError))
52
            self.assertNotEqual(e.status, None)
53
            self.assertNotEqual(e.message, None)
54
            self.assertNotEqual(e.errorside, None)
55
56
    def test_client_methods(self):
57
        """Test Client API methods"""
58
        print('Test Client API methods')
59
60
        project = self._client.get_projects_list()[0]
61
        self.assertNotEqual(project.id, 0)
62
        project = self._client.get_project(project_id=project.id)
63
        self.assertNotEqual(project.id, 0)
64
        project = self._client.get_project_export(project_id=project.id)
65
        self.assertNotEqual(project.id, 0)
66
67
        page = self._client.get_pages_list(project_id=project.id)[0]
68
        self.assertNotEqual(page.id, 0)
69
        page = self._client.get_page(page_id=page.id)
70
        self.assertNotEqual(page.id, 0)
71
        page = self._client.get_page_full(page_id=page.id)
72
        self.assertNotEqual(page.id, 0)
73
        page = self._client.get_page_export(page_id=page.id)
74
        self.assertNotEqual(page.id, 0)
75
        page = self._client.get_page_full_export(page_id=page.id)
76
        self.assertNotEqual(page.id, 0)
77
78
79
if __name__ == '__main__':
80
    unittest.main()
81