import os
import sys
import time

from magnolia.utility import *
from magnolia.utility import LOG as L
from magnolia.script.kancolle import testcase_normal

class TestCase(testcase_normal.TestCase_Normal):
    def __init__(self, *args, **kwargs):
        super(TestCase, self).__init__(*args, **kwargs)

    @classmethod
    def setUpClass(cls):
        L.info("*** Start TestCase   : %s *** " % __file__)

    def test_1(self):
        L.info("*** Exercises ***")
        try:
            self.minicap_start(); time.sleep(2)
            self.assertTrue(self.initialize(self.get("args.deploy")), "Can't Login & Check Start.")
            while self.expedition_result(): time.sleep(1)
            self.slack_message(self.get("bot.exercises"))
            self.assertTrue(self.exercises(), "Can't Exercises.")
            while self.expedition_result(): time.sleep(1)
            self.assertTrue(self.supply(self.get("args.fleet")), "Can't Supply.")
            self.assertTrue(self.home())
            while self.expedition_result(): time.sleep(1)
            self.minicap_finish(); time.sleep(2)
        except Exception as e:
            L.warning(type(e).__name__ + ": " + str(e))
            self.minicap_finish(); time.sleep(2)
            self.minicap_create_video()
            self.fail("Error Ocurred. Please Check the Video.")

    @classmethod
    def tearDownClass(cls):
        L.info("*** End TestCase     : %s *** " % __file__)
