-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathintegration_tests_hosting.py
More file actions
50 lines (38 loc) · 1.56 KB
/
integration_tests_hosting.py
File metadata and controls
50 lines (38 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
import uuid
from tests.integration_test import InstanceMixin, IntegrationTest
try:
# python2
from StringIO import StringIO
except ImportError:
# python3
from io import StringIO
class HostingIntegrationTests(InstanceMixin, IntegrationTest):
def test_create_file(self):
hosting = self._create_hosting('created-xyz')
a_hosting_file = StringIO()
a_hosting_file.write('h1 {color: #541231;}')
a_hosting_file.seek(0)
hosting_file = hosting.upload_file(path='styles/main.css', file=a_hosting_file)
self.assertEqual(hosting_file.path, 'styles/main.css')
def test_set_default(self):
hosting = self._create_hosting('default-xyz')
hosting = hosting.set_default()
self.assertTrue('default', hosting.is_default)
def test_update_file(self):
hosting = self._create_hosting('update-xyz')
a_hosting_file = StringIO()
a_hosting_file.write('h1 {color: #541231;}')
a_hosting_file.seek(0)
hosting.upload_file(path='styles/main.css', file=a_hosting_file)
a_hosting_file = StringIO()
a_hosting_file.write('h2 {color: #541231;}')
a_hosting_file.seek(0)
hosting_file = hosting.update_file(path='styles/main.css', file=a_hosting_file)
self.assertEqual(hosting_file.path, 'styles/main.css')
def _create_hosting(self, name):
return self.instance.hostings.create(
name=name,
description='desc',
domains=['test.test{}.io'.format(uuid.uuid4().hex[:5])]
)