# Path: ship/utils/fileloaders/fileloader.py
# class FileLoader(object):
#     def __init__(self):
#     def loadFile(self, filepath, arg_dict={}):
# 
# Path: ship/tuflow/tuflowfactory.py
# class TuflowFactory(object):
#     def getTuflowPart(cls, line, parent, part_type=None, logic=None):
#     def createModelVariableType(line, parent, **kwargs):
#     def createUserVariableType(line, parent, **kwargs):
#     def createBcEventVariable(line, parent, **kwargs):
#     def createVariableType(line, parent, **kwargs):
#     def createKeyValueType(line, parent, **kwargs):
#     def createDataType(line, parent, **kwargs):
#     def createResultType(line, parent, **kwargs):
#     def createGisType(line, parent, **kwargs):
#     def createModelType(line, parent, **kwargs):
#     def createIfLogic(parent, commands, terms, comments):
#     def createBlockLogic(parent, commands, terms, comments):
# def partsFromPipedFiles(part_type, parent, **kwargs):
# def assignSiblings(parts):
# def checkMultiTypes(line, part_type):
# def checkEstryAuto(line, parent):
# def checkIsComment(line):
# def takeParentType(path):
# def getExtension(path, upper=True):
# def breakLine(line):
# def separateComment(instruction):
# def resolveResult(result_part):
# 
# Path: integration_tests/utils.py
# def softAssertion(var, value, testEqual=True):
# def softAssertionIn(var, value, testIn=True):


import os
import copy
from ship.utils.fileloaders import fileloader
from ship.tuflow import tuflowfactory as factory
from integration_tests import utils
class TuflowUpdateTests(object):
    
    def runTests(self):
        self.loadTuflowModel()
        self.test_changeActiveStatus()
        self.test_addPartToPartHolder()
        self.test_removePartFromPartHolder()
        self.test_addPartToLogicHolder()
        self.test_removePartFromLogicHolder()

    
    def loadTuflowModel(self):
        print ('Loading tuflow model...')
        path = "integration_tests/test_data/model1/tuflow/runs/test_run1.tcf"
        path = os.path.normpath(os.path.join(os.getcwd(), path))
        loader = fileloader.FileLoader()
        self.tuflow = loader.loadFile(path)
        utils.softAssertion(self.tuflow.missing_model_files, [])
        print ('Tuflow model load complete.')
    
    def test_changeActiveStatus(self):
        print ('Testing update active status...')
        tuflow = copy.deepcopy(self.tuflow)
        control = tuflow.control_files['TGC']

        # Make sure we know what it is before
        zpt_part = control.contains(command="Set Zpts", variable="2",
                                    parent_filename="test_trd2")
        zln_part = control.contains(command="Z Line THIN", filename="zln_shiptest_trd_v2")
        parts = zpt_part + zln_part

# Path: ship/utils/fileloaders/fileloader.py
# class FileLoader(object):
#     def __init__(self):
#     def loadFile(self, filepath, arg_dict={}):
# 
# Path: ship/tuflow/tuflowfactory.py
# class TuflowFactory(object):
#     def getTuflowPart(cls, line, parent, part_type=None, logic=None):
#     def createModelVariableType(line, parent, **kwargs):
#     def createUserVariableType(line, parent, **kwargs):
#     def createBcEventVariable(line, parent, **kwargs):
#     def createVariableType(line, parent, **kwargs):
#     def createKeyValueType(line, parent, **kwargs):
#     def createDataType(line, parent, **kwargs):
#     def createResultType(line, parent, **kwargs):
#     def createGisType(line, parent, **kwargs):
#     def createModelType(line, parent, **kwargs):
#     def createIfLogic(parent, commands, terms, comments):
#     def createBlockLogic(parent, commands, terms, comments):
# def partsFromPipedFiles(part_type, parent, **kwargs):
# def assignSiblings(parts):
# def checkMultiTypes(line, part_type):
# def checkEstryAuto(line, parent):
# def checkIsComment(line):
# def takeParentType(path):
# def getExtension(path, upper=True):
# def breakLine(line):
# def separateComment(instruction):
# def resolveResult(result_part):
# 
# Path: integration_tests/utils.py
# def softAssertion(var, value, testEqual=True):
# def softAssertionIn(var, value, testIn=True):


# Path: integration_tests/test_tuflowupdate.py
import os
import copy
from ship.utils.fileloaders import fileloader
from ship.tuflow import tuflowfactory as factory
from integration_tests import utils

class TuflowUpdateTests(object):
    
    def runTests(self):
        self.loadTuflowModel()
        self.test_changeActiveStatus()
        self.test_addPartToPartHolder()
        self.test_removePartFromPartHolder()
        self.test_addPartToLogicHolder()
        self.test_removePartFromLogicHolder()

    
    def loadTuflowModel(self):
        print ('Loading tuflow model...')
        path = "integration_tests/test_data/model1/tuflow/runs/test_run1.tcf"
        path = os.path.normpath(os.path.join(os.getcwd(), path))
        loader = fileloader.FileLoader()
        self.tuflow = loader.loadFile(path)
        utils.softAssertion(self.tuflow.missing_model_files, [])
        print ('Tuflow model load complete.')
    
    def test_changeActiveStatus(self):
        print ('Testing update active status...')
        tuflow = copy.deepcopy(self.tuflow)
        control = tuflow.control_files['TGC']

        # Make sure we know what it is before
        zpt_part = control.contains(command="Set Zpts", variable="2",
                                    parent_filename="test_trd2")
        zln_part = control.contains(command="Z Line THIN", filename="zln_shiptest_trd_v2")
        parts = zpt_part + zln_part

        utils.softAssertion(len(parts), 3)