Skip to content
Prev Previous commit
Next Next commit
[LIB-965] correct hosting tests;
  • Loading branch information
opalczynski committed Oct 28, 2016
commit 12198dbaed19c921c61787b3383eb9114f0ba610
25 changes: 14 additions & 11 deletions tests/integration_tests_hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,38 @@

class HostingIntegrationTests(InstanceMixin, IntegrationTest):

def setUp(self):
self.hosting = self.instance.hostings.create(
name='test12',
description='desc',
domains=['test.test{}.io'.format(uuid.uuid4().hex[:5])]
)

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 = self.hosting.upload_file(path='styles/main.css', file=a_hosting_file)
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.hosting.set_default()
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)

self.hosting.upload_file(path='styles/main.css', file=a_hosting_file)
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 = self.hosting.update_file(path='styles/main.css', file=a_hosting_file)
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])]
)