Esempio n. 1
0
 def populate_instance():
     first_item = Instance()
     first_item.id = 608
     first_item.name = 'My old list item'
     first_item.description = 'My description'
     first_item.image = 1
     first_item.memory = 512
     first_item.disk = 30
     first_item.bridge = 2
     first_item.status = 'Stopped'
     first_item.create_disk = False
     first_item.create_path = False
     first_item.save()
     return first_item
Esempio n. 2
0
 def populate_instances(self):
     first_item = Instance()
     first_item.name = 'My old list item'
     first_item.description = 'My description'
     first_item.image = 1
     first_item.memory = 512
     first_item.disk = 30
     first_item.bridge = 2
     first_item.create_disk = False
     first_item.create_path = False
     first_item.save()
Esempio n. 3
0
    def test_vps_view_instance(self):
        first_item = Instance()
        first_item.name = 'My old list item'
        first_item.description = 'My description'
        first_item.image = 1
        first_item.memory = 512
        first_item.disk = 30
        first_item.bridge = 2
        first_item.create_disk = False
        first_item.create_path = False
        first_item.save()

        disk = Disk()
        disk.name = 'My old list item'
        disk.instance = first_item
        disk.save()

        network = Network()
        network.name = 'Another test'
        network.instance = first_item
        network.save()

        response = self.client.get('/vps/1/')
        self.assertEquals(response.status_code, 200)
        self.assertTemplateUsed('viewvps.html')
        self.assertContains(response, 'VPS Manager')
Esempio n. 4
0
    def populate_instances():
        first_item = Instance()
        first_item.name = 'My old list item'
        first_item.description = 'My description'
        first_item.image = 1
        first_item.memory = 512
        first_item.disk = 30
        first_item.bridge = 2
        first_item.create_disk = False
        first_item.create_path = False
        first_item.save()

        second_item = Disk()
        second_item.instance = first_item
        second_item.name = 'test'
        second_item.size = int(30)
        second_item.save()
Esempio n. 5
0
    def test_deleting_items(self):
        self.populate_db()

        second_item = Instance()
        second_item.name = 'Instance2'
        second_item.description = 'my instance'
        second_item.memory = 512
        second_item.disk = 20
        second_item.bridge = 1
        second_item.console = 204
        second_item.image = 1
        second_item.path = 'mypath'
        second_item.start_script = 'startscript.sh'
        second_item.stop_script = 'stopscript.sh'
        second_item.create_disk = True
        second_item.create_path = True
        second_item.ip = '1.2.3.4'

        second_item.save()
        saved_items = Instance.objects.all()
        self.assertEqual(saved_items.count(), 2)

        response = second_item.delete()
        saved_items = Instance.objects.all()
        self.assertEqual(saved_items.count(), 1)
Esempio n. 6
0
 def populate_db(self):
     first_item = Instance()
     first_item.name = 'Instance1'
     first_item.description = 'my instance'
     first_item.memory = 512
     first_item.disk = 20
     first_item.bridge = 1
     first_item.console = 204
     first_item.image = 1
     first_item.path = 'mypath'
     first_item.start_script = 'startscript.sh'
     first_item.stop_script = 'stopscript.sh'
     first_item.create_disk = True
     first_item.create_path = True
     first_item.ip = '1.2.3.4'
     first_item.save()
     return first_item
Esempio n. 7
0
    def test_saving_and_retrieving_items(self):
        first_item = self.populate_db()

        second_item = Instance()
        second_item.name = 'Instance2'
        second_item.description = 'my instance'
        second_item.memory = 512
        second_item.disk = 20
        second_item.console = 204
        second_item.image = 1
        second_item.path = 'mypath'
        second_item.start_script = 'startscript.sh'
        second_item.stop_script = 'stopscript.sh'
        second_item.create_disk = True
        second_item.create_path = True
        second_item.ip = '1.2.3.4'

        second_item.save()

        saved_items = Instance.objects.all()
        self.assertEqual(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]
        self.assertEqual(first_saved_item.name, 'Instance1')
        self.assertEqual(first_saved_item.description, 'my instance')
        self.assertEqual(first_saved_item.memory, 512)
        self.assertEqual(first_saved_item.console, 204)
        self.assertEqual(first_saved_item.image, 1)
        self.assertEqual(first_saved_item.path, 'mypath')
        self.assertEqual(first_saved_item.start_script, 'startscript.sh')
        self.assertEqual(first_saved_item.stop_script, 'stopscript.sh')
        self.assertEqual(first_saved_item.create_disk, True)
        self.assertEqual(first_saved_item.create_path, True)
        self.assertEqual(first_saved_item.ip, '1.2.3.4')
        self.assertEqual(second_saved_item.name, 'Instance2')
        self.assertEqual(second_saved_item.description, 'my instance')
        self.assertEqual(second_saved_item.memory, 512)
        self.assertEqual(second_saved_item.console, 204)
        self.assertEqual(second_saved_item.image, 1)
        self.assertEqual(second_saved_item.path, 'mypath')
        self.assertEqual(second_saved_item.start_script, 'startscript.sh')
        self.assertEqual(second_saved_item.stop_script, 'stopscript.sh')
        self.assertEqual(second_saved_item.create_disk, True)
        self.assertEqual(second_saved_item.create_path, True)
        self.assertEqual(second_saved_item.ip, '1.2.3.4')