def test_fault(self):
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.fault_message,
                      result['instance']['fault']['message'])
     self.assertEqual(self.fault_details,
                      result['instance']['fault']['details'])
     self.assertEqual(self.fault_date,
                      result['instance']['fault']['created'])
Beispiel #2
0
 def test_fault(self):
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.fault_message,
                      result['instance']['fault']['message'])
     self.assertEqual(self.fault_details,
                      result['instance']['fault']['details'])
     self.assertEqual(self.fault_date,
                      result['instance']['fault']['created'])
Beispiel #3
0
 def test_data_ip(self):
     self.instance.hostname = None
     view = InstanceDetailView(self.instance, Mock())
     result = view.data()
     self.assertEqual(self.instance.created, result['instance']['created'])
     self.assertEqual(self.instance.updated, result['instance']['updated'])
     self.assertEqual(self.instance.datastore_version.name,
                      result['instance']['datastore']['version'])
     self.assertNotIn('hostname', result['instance'])
     self.assertEqual([self.ip], result['instance']['ip'])
 def test_data_ip(self):
     self.instance.hostname = None
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.instance.created, result['instance']['created'])
     self.assertEqual(self.instance.updated, result['instance']['updated'])
     self.assertEqual(self.instance.datastore_version.name,
                      result['instance']['datastore']['version'])
     self.assertNotIn('hostname', result['instance'])
     self.assertEqual([self.ip], result['instance']['ip'])
 def test_data_hostname(self):
     view = InstanceDetailView(self.instance, Mock())
     result = view.data()
     self.assertEqual(self.instance.created, result['instance']['created'])
     self.assertEqual(self.instance.updated, result['instance']['updated'])
     self.assertEqual(self.instance.datastore_version.name,
                      result['instance']['datastore']['version'])
     self.assertEqual(self.instance.hostname,
                      result['instance']['hostname'])
     self.assertNotIn('ip', result['instance'])
Beispiel #6
0
 def test_data_hostname(self):
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.instance.created, result['instance']['created'])
     self.assertEqual(self.instance.updated, result['instance']['updated'])
     self.assertEqual(self.instance.datastore_version.name,
                      result['instance']['datastore']['version'])
     self.assertEqual(self.instance.hostname,
                      result['instance']['hostname'])
     self.assertNotIn('ip', result['instance'])
Beispiel #7
0
    def test_access(self):
        instance = MagicMock()
        instance.hostname = None
        instance.get_visible_ip_addresses.return_value = [{
            'address': '10.111.0.27',
            'type': 'private'
        }]
        instance.access = None
        instance.slaves = []

        view = InstanceDetailView(instance, self.req)
        data = view.data()['instance']

        self.assertFalse(data['access']['is_public'])

        instance.get_visible_ip_addresses.return_value = [{
            'address': '10.111.0.27',
            'type': 'private'
        }, {
            'address': '172.30.5.107',
            'type': 'public'
        }]

        view = InstanceDetailView(instance, self.req)
        data = view.data()['instance']

        self.assertTrue(data['access']['is_public'])
 def test_non_admin_view(self):
     self.context.is_admin = False
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertNotIn('server_id', result['instance'])
     self.assertNotIn('volume_id', result['instance'])
 def test_locality(self):
     self.instance.hostname = None
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.instance.locality,
                      result['instance']['locality'])
Beispiel #10
0
 def test_non_admin_view(self):
     self.context.is_admin = False
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertNotIn('server_id', result['instance'])
     self.assertNotIn('volume_id', result['instance'])
Beispiel #11
0
 def test_locality(self):
     self.instance.hostname = None
     view = InstanceDetailView(self.instance, self.req)
     result = view.data()
     self.assertEqual(self.instance.locality,
                      result['instance']['locality'])