# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

""" Boilerplate Marvin tests for the CloudStack fizzBuzz API.

Run with:
    nosetests3 --with-marvin --marvin-config=env.cfg -s -a tags=simulator test_fizzbuzz.py
"""

from nose.plugins.attrib import attr

from marvin.cloudstackAPI import fizzBuzz
from marvin.cloudstackTestCase import cloudstackTestCase


class TestFizzBuzz(cloudstackTestCase):

    @classmethod
    def setUpClass(cls):
        cls.testClient = super(TestFizzBuzz, cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()
        cls._cleanup = []

    @classmethod
    def tearDownClass(cls):
        super(TestFizzBuzz, cls).tearDownClass()

    def setUp(self):
        self.apiclient = self.testClient.getApiClient()
        self.cleanup = []

    def tearDown(self):
        super(TestFizzBuzz, self).tearDown()

    def call_fizzbuzz(self, number):
        """Calls the fizzBuzz API with the given number and returns the answer."""
        cmd = fizzBuzz.fizzBuzzCmd()
        cmd.number = number
        response = self.apiclient.fizzBuzz(cmd)
        return response.answer

    @attr(tags=["simulator"], required_hardware="false")
    def test_00_example(self):
        """Example test: fizzBuzz(3) must return "fizz"."""
        self.assertEqual(self.call_fizzbuzz(3), "fizz")

    # Add your test cases for each level below.
