Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / api / tests / extensions.py @ ba777b02

History | View | Annotate | Download (2.5 kB)

1 6966e8df Christos Stavrakakis
# Copyright 2013 GRNET S.A. All rights reserved.
2 6966e8df Christos Stavrakakis
#
3 6966e8df Christos Stavrakakis
# Redistribution and use in source and binary forms, with or
4 6966e8df Christos Stavrakakis
# without modification, are permitted provided that the following
5 6966e8df Christos Stavrakakis
# conditions are met:
6 6966e8df Christos Stavrakakis
#
7 6966e8df Christos Stavrakakis
#   1. Redistributions of source code must retain the above
8 6966e8df Christos Stavrakakis
#      copyright notice, this list of conditions and the following
9 6966e8df Christos Stavrakakis
#      disclaimer.
10 6966e8df Christos Stavrakakis
#
11 6966e8df Christos Stavrakakis
#   2. Redistributions in binary form must reproduce the above
12 6966e8df Christos Stavrakakis
#      copyright notice, this list of conditions and the following
13 6966e8df Christos Stavrakakis
#      disclaimer in the documentation and/or other materials
14 6966e8df Christos Stavrakakis
#      provided with the distribution.
15 6966e8df Christos Stavrakakis
#
16 6966e8df Christos Stavrakakis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 6966e8df Christos Stavrakakis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 6966e8df Christos Stavrakakis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 6966e8df Christos Stavrakakis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 6966e8df Christos Stavrakakis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 6966e8df Christos Stavrakakis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 6966e8df Christos Stavrakakis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 6966e8df Christos Stavrakakis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 6966e8df Christos Stavrakakis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 6966e8df Christos Stavrakakis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 6966e8df Christos Stavrakakis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 6966e8df Christos Stavrakakis
# POSSIBILITY OF SUCH DAMAGE.
28 6966e8df Christos Stavrakakis
#
29 6966e8df Christos Stavrakakis
# The views and conclusions contained in the software and
30 6966e8df Christos Stavrakakis
# documentation are those of the authors and should not be
31 6966e8df Christos Stavrakakis
# interpreted as representing official policies, either expressed
32 6966e8df Christos Stavrakakis
# or implied, of GRNET S.A.
33 6966e8df Christos Stavrakakis
34 6966e8df Christos Stavrakakis
import json
35 6966e8df Christos Stavrakakis
36 6966e8df Christos Stavrakakis
from snf_django.utils.testing import BaseAPITest
37 6966e8df Christos Stavrakakis
from synnefo.lib.services import get_service_path
38 6966e8df Christos Stavrakakis
from synnefo.cyclades_settings import cyclades_services
39 6966e8df Christos Stavrakakis
from synnefo.lib import join_urls
40 6966e8df Christos Stavrakakis
41 6966e8df Christos Stavrakakis
COMPUTE_URL = get_service_path(cyclades_services, 'compute',
42 6966e8df Christos Stavrakakis
                               version='v2.0')
43 6966e8df Christos Stavrakakis
EXTENSIONS_URL = join_urls(COMPUTE_URL, "extensions/")
44 6966e8df Christos Stavrakakis
45 6966e8df Christos Stavrakakis
46 6966e8df Christos Stavrakakis
class ExtensionsAPITest(BaseAPITest):
47 fe7b1d66 Christos Stavrakakis
    def test_list(self):
48 6966e8df Christos Stavrakakis
        response = self.get(EXTENSIONS_URL, "user")
49 6966e8df Christos Stavrakakis
        self.assertSuccess(response)
50 6966e8df Christos Stavrakakis
        extensions = json.loads(response.content)["extensions"]
51 6966e8df Christos Stavrakakis
        self.assertEqual(extensions, [])
52 fe7b1d66 Christos Stavrakakis
53 fe7b1d66 Christos Stavrakakis
    def test_get(self):
54 fe7b1d66 Christos Stavrakakis
        response = self.get(join_urls(EXTENSIONS_URL, "SNF"), "user")
55 fe7b1d66 Christos Stavrakakis
        self.assertEqual(response.status_code, 404)
56 fe7b1d66 Christos Stavrakakis
        response = self.get(join_urls(EXTENSIONS_URL, "SNF_asfas_da"), "user")
57 fe7b1d66 Christos Stavrakakis
        self.assertEqual(response.status_code, 404)
58 fe7b1d66 Christos Stavrakakis
        response = self.get(join_urls(EXTENSIONS_URL, "SNF-AD"), "user")
59 fe7b1d66 Christos Stavrakakis
        self.assertEqual(response.status_code, 404)