Esempio n. 1
0
    def test_create_instance_with_network(self):
        first_item = self.populate_db()

        first_disk = Disk(name='test', size=20, instance=first_item)
        first_disk.save()
        first_nw = Network(name='test', bridge=1, instance=first_item)
        first_nw.save()
Esempio n. 2
0
    def test_create_and_retrieve_instance_with_network(self):
        first_item = self.populate_db()

        first_network = Network(name='test', bridge=1, instance=first_item)
        first_network.save()

        instance = Instance.objects.all().filter(pk=first_item.id)
        network = Network.objects.all().filter(instance_id=first_item.id)

        item = instance[0]
        self.assertEqual(item.name, 'Instance1')
        self.assertEqual(network.count(), 1)
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 test_stop_vps(self):
        first_item = self.populate_instance()

        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/stop/608/')
        self.assertEquals(response.status_code, 200)
Esempio n. 5
0
    def test_start_vps(self, fake_make_call_to_vpssvr):
        fake_make_call_to_vpssvr.return_value = True

        first_item = self.populate_instance()

        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/stop/608/')
        self.assertEquals(response.status_code, 200)