|
13 | 13 |
|
14 | 14 | class HostingIntegrationTests(InstanceMixin, IntegrationTest): |
15 | 15 |
|
16 | | - def setUp(self): |
17 | | - self.hosting = self.instance.hostings.create( |
18 | | - label='test12', |
19 | | - description='desc', |
20 | | - domains=['test.test{}.io'.format(uuid.uuid4().hex[:5])] |
21 | | - ) |
22 | | - |
23 | 16 | def test_create_file(self): |
| 17 | + hosting = self._create_hosting('created-xyz') |
24 | 18 | a_hosting_file = StringIO() |
25 | 19 | a_hosting_file.write('h1 {color: #541231;}') |
26 | 20 | a_hosting_file.seek(0) |
27 | 21 |
|
28 | | - hosting_file = self.hosting.upload_file(path='styles/main.css', file=a_hosting_file) |
| 22 | + hosting_file = hosting.upload_file(path='styles/main.css', file=a_hosting_file) |
29 | 23 | self.assertEqual(hosting_file.path, 'styles/main.css') |
30 | 24 |
|
31 | 25 | def test_set_default(self): |
32 | | - hosting = self.hosting.set_default() |
33 | | - self.assertIn('default', hosting.domains) |
| 26 | + hosting = self._create_hosting('default-xyz') |
| 27 | + hosting = hosting.set_default() |
| 28 | + self.assertTrue('default', hosting.is_default) |
34 | 29 |
|
35 | 30 | def test_update_file(self): |
| 31 | + hosting = self._create_hosting('update-xyz') |
36 | 32 | a_hosting_file = StringIO() |
37 | 33 | a_hosting_file.write('h1 {color: #541231;}') |
38 | 34 | a_hosting_file.seek(0) |
39 | 35 |
|
40 | | - self.hosting.upload_file(path='styles/main.css', file=a_hosting_file) |
| 36 | + hosting.upload_file(path='styles/main.css', file=a_hosting_file) |
41 | 37 |
|
42 | 38 | a_hosting_file = StringIO() |
43 | 39 | a_hosting_file.write('h2 {color: #541231;}') |
44 | 40 | a_hosting_file.seek(0) |
45 | 41 |
|
46 | | - hosting_file = self.hosting.update_file(path='styles/main.css', file=a_hosting_file) |
| 42 | + hosting_file = hosting.update_file(path='styles/main.css', file=a_hosting_file) |
47 | 43 | self.assertEqual(hosting_file.path, 'styles/main.css') |
| 44 | + |
| 45 | + def _create_hosting(self, name): |
| 46 | + return self.instance.hostings.create( |
| 47 | + name=name, |
| 48 | + description='desc', |
| 49 | + domains=['test.test{}.io'.format(uuid.uuid4().hex[:5])] |
| 50 | + ) |
0 commit comments