Esempio n. 1
0
    def test_post(self, _post):
        """`post` will POST to the smart url."""
        lxd = api._APINode(self.ROOT)

        lxd.fake.post()

        _post.assert_called_once_with('{}/{}'.format(self.ROOT, 'fake'))
Esempio n. 2
0
    def test_get(self, _get):
        """`get` will make a request to the smart url."""
        lxd = api._APINode(self.ROOT)

        lxd.fake.get()

        _get.assert_called_once_with('{}/{}'.format(self.ROOT, 'fake'))
Esempio n. 3
0
    def test_getitem_integer(self):
        """`__getitem__` with an integer allows dynamic integer url parts."""
        lxd = api._APINode(self.ROOT)  # NOQA

        self.assertEqual(
            '{}/fake/0'.format(self.ROOT),
            lxd.fake[0]._api_endpoint)
Esempio n. 4
0
    def test_getitem(self):
        """`__getitem__` enables dynamic url parts."""
        lxd = api._APINode(self.ROOT)  # NOQA

        self.assertEqual(
            '{}/fake/path'.format(self.ROOT),
            lxd.fake['path']._api_endpoint)
Esempio n. 5
0
    def test_getattr_nested(self):
        """Nested objects return a more detailed path."""
        lxd = api._APINode(self.ROOT)  # NOQA

        self.assertEqual(
            '{}/fake/path'.format(self.ROOT),
            lxd.fake.path._api_endpoint)
Esempio n. 6
0
    def test_getattr(self):
        """`__getattr__` returns a nested node."""
        lxd = api._APINode(self.ROOT)

        self.assertEqual('{}/fake'.format(self.ROOT), lxd.fake._api_endpoint)