def test_get_detail_with_action(self, m):
        payload = {"a": "b", "c": "d"}
        m.get('http://iotile.test/api/v1/test/my-detail/action/',
              text=json.dumps(payload))

        api = Api(domain='http://iotile.test')
        resp = api.test('my-detail').action.url()
        self.assertEqual(resp,
                         'http://iotile.test/api/v1/test/my-detail/action/')
        resp = api.test('my-detail').action.get()
        self.assertEqual(resp, {'a': 'b', 'c': 'd'})
    def test_delete(self, m):
        result = {"id": 1}
        m.delete('http://iotile.test/api/v1/test/my-detail/',
                 text=json.dumps(result))

        api = Api(domain='http://iotile.test')
        deleted = api.test('my-detail').delete()
        self.assertTrue(deleted)
    def test_get_detail_with_extra_args(self, m):
        payload = {"a": "b", "c": "d"}
        m.get('http://iotile.test/api/v1/test/my-detail/',
              text=json.dumps(payload))

        api = Api(domain='http://iotile.test')
        resp = api.test('my-detail').get(foo='bar')
        self.assertEqual(resp, {'a': 'b', 'c': 'd'})
    def test_put(self, m):
        payload = {"foo": ["a", "b", "c"]}
        result = {"id": 1}
        m.put('http://iotile.test/api/v1/test/my-detail/',
              text=json.dumps(result))

        api = Api(domain='http://iotile.test')
        resp = api.test('my-detail').put(payload)
        self.assertEqual(resp['id'], 1)