# -*- coding: utf-8 -*-

from mock import sentinel, MagicMock

from sceptre.stack import Stack
from sceptre.template import Template


class TestStack(object):

    def setup_method(self, test_method):
        self.stack = Stack(
            name=sentinel.stack_name, project_code=sentinel.project_code,
            template_path=sentinel.template_path, region=sentinel.region,
            profile=sentinel.profile, parameters={"key1": "val1"},
            sceptre_user_data=sentinel.sceptre_user_data, hooks={},
            s3_details=None, dependencies=sentinel.dependencies,
            role_arn=sentinel.role_arn, protected=False,
            tags={"tag1": "val1"}, external_name=sentinel.external_name,
            notifications=[sentinel.notification],
            on_failure=sentinel.on_failure,
            stack_timeout=sentinel.stack_timeout
        )
        self.stack._template = MagicMock(spec=Template)

    def test_initiate_stack(self):
        stack = Stack(
            name=sentinel.stack_name, project_code=sentinel.project_code,
            template_path=sentinel.template_path, region=sentinel.region,
            external_name=sentinel.external_name
        )
        assert stack.name == sentinel.stack_name
        assert stack.project_code == sentinel.project_code
        assert stack.external_name == sentinel.external_name
        assert stack.hooks == {}
        assert stack.parameters == {}
        assert stack.sceptre_user_data == {}
        assert stack.template_path == sentinel.template_path
        assert stack.s3_details is None
        assert stack._template is None
        assert stack.protected is False
        assert stack.role_arn is None
        assert stack.dependencies == []
        assert stack.tags == {}
        assert stack.notifications == []
        assert stack.on_failure is None

    def test_repr(self):
        assert self.stack.__repr__() == \
            "sceptre.stack.Stack(" \
            "name='sentinel.stack_name', " \
            "project_code='sentinel.project_code', " \
            "template_path='sentinel.template_path', " \
            "region='sentinel.region', " \
            "profile='sentinel.profile', parameters='{'key1': 'val1'}', " \
            "sceptre_user_data='sentinel.sceptre_user_data', " \
            "hooks='{}', s3_details='None', " \
            "dependencies='sentinel.dependencies', "\
            "role_arn='sentinel.role_arn', " \
            "protected='False', tags='{'tag1': 'val1'}', " \
            "external_name='sentinel.external_name', " \
            "notifications='[sentinel.notification]', " \
            "on_failure='sentinel.on_failure', " \
            "stack_timeout='sentinel.stack_timeout'" \
            ")"
