コード例 #1
0
    def test_fetch_error(self):
        """LXDAPIException is raised on fetch error."""
        def error(_, context):
            context.status_code = 500
            return json.dumps({
                'type': 'error',
                'error': 'Not found',
                'error_code': 500
            })

        self.add_rule({
            'text': error,
            'method': 'GET',
            'url': r'^http://pylxd.test/1.0/networks/eth0$',
        })
        network = models.Network(self.client, name='eth0')

        self.assertRaises(exceptions.LXDAPIException, network.sync)
コード例 #2
0
    def test_fetch_error(self):
        """LXDAPIException is raised on fetch error."""
        def error(_, context):
            context.status_code = 500
            return json.dumps({
                "type": "error",
                "error": "Not found",
                "error_code": 500
            })

        self.add_rule({
            "text": error,
            "method": "GET",
            "url": r"^http://pylxd.test/1.0/networks/eth0$",
        })
        network = models.Network(self.client, name="eth0")

        self.assertRaises(exceptions.LXDAPIException, network.sync)
コード例 #3
0
    def test_delete(self):
        """A network is deleted."""
        network = models.Network(self.client, name='eth0')

        network.delete()
コード例 #4
0
    def test_save(self):
        """save is not implemented in networks."""
        an_network = models.Network(self.client, name='lo')

        with self.assertRaises(NotImplementedError):
            an_network.save()
コード例 #5
0
    def test_partial(self):
        """A partial network is synced."""
        an_network = models.Network(self.client, name='lo')

        self.assertEqual('loopback', an_network.type)