# -*- encoding: utf-8 -*-
#
# Copyright (c) 2014, OVH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Except as contained in this notice, the name of OVH and or its trademarks
# (and among others RunAbove) shall not be used in advertising or otherwise to
# promote the sale, use or other dealings in this Software without prior
# written authorization from OVH.

import unittest
import json
import mock
import runabove

from sys import version_info

if version_info[0] >= 3:
    unicode = str  # Python 3 str replaces unicode

class TestContainerManager(unittest.TestCase):
    """Test storage using RunAbove API.

    To play with objects we use swiftclient and we trust it's
    tested properly :)
    """

    name  = 'test2'
    region = 'SBG-1'
    answer_list = '''[
        {
            "totalObjects": 5,
            "name": "test",
            "stored": 1024,
            "region": "SBG-1"
        },
        {
            "totalObjects": 0,
            "name": "test2",
            "stored": 0,
            "region": "SBG-1"
        }
    ]'''

    answer_one = '''{
        "totalObjects": 0,
        "name": "test2",
        "stored": 0,
        "region": "SBG-1"
    }'''

    answer_token = '''{
      "token": {
        "catalog": [
          {
            "endpoints": [
              {
                "id": "af64asqa26fda457c0e974f3f",
                "interface": "public",
                "legacy_endpoint_id": "fa56f4as64c9a8f4asdf496",
                "region": "SBG-1",
                "url": "https://network.compute.sbg-1.runabove.io/"
              },