# 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
        line2 = "Timestep == 22 ! timestep 22 comment"
        varpart2 = factory.TuflowFactory.getTuflowPart(line2, tgc)[0]
        existing_part = control.contains(filename='test_trd2')[0]
        control.parts.add(varpart, after=existing_part)
        control.parts.add(varpart2, before=existing_part)

        line3 = "Timestep == 32 ! timestep 23 comment"
        varpart3 = factory.TuflowFactory.getTuflowPart(line3, existing_part)[0]
        control.parts.add(varpart3)

        found = False
        for i, p in enumerate(control.parts):
            if p == existing_part:
                found = True
                utils.softAssertion(control.parts[i+1], varpart)
                utils.softAssertion(control.parts[i+1].associates.logic, existing_part.associates.logic)
                utils.softAssertion(control.parts[i-1], varpart2)
                utils.softAssertion(control.parts[i-1].associates.logic, existing_part.associates.logic)
        if not found:
            raise TestError('Failed to add part to PartHolder')
        
        
        utils.softAssertion(control.parts[-1] ,varpart3, False)
        utils.softAssertion(varpart3.associates.parent ,tgc, False)
        
        trd_index = control.parts.lastIndexOfParent(varpart3.associates.parent)
        utils.softAssertion(control.parts[trd_index], varpart3)
        
        print ('Done')
    

# 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

        line2 = "Timestep == 22 ! timestep 22 comment"
        varpart2 = factory.TuflowFactory.getTuflowPart(line2, tgc)[0]
        existing_part = control.contains(filename='test_trd2')[0]
        control.parts.add(varpart, after=existing_part)
        control.parts.add(varpart2, before=existing_part)

        line3 = "Timestep == 32 ! timestep 23 comment"
        varpart3 = factory.TuflowFactory.getTuflowPart(line3, existing_part)[0]
        control.parts.add(varpart3)

        found = False
        for i, p in enumerate(control.parts):
            if p == existing_part:
                found = True
                utils.softAssertion(control.parts[i+1], varpart)
                utils.softAssertion(control.parts[i+1].associates.logic, existing_part.associates.logic)
                utils.softAssertion(control.parts[i-1], varpart2)
                utils.softAssertion(control.parts[i-1].associates.logic, existing_part.associates.logic)
        if not found:
            raise TestError('Failed to add part to PartHolder')
        
        
        utils.softAssertion(control.parts[-1] ,varpart3, False)
        utils.softAssertion(varpart3.associates.parent ,tgc, False)
        
        trd_index = control.parts.lastIndexOfParent(varpart3.associates.parent)
        utils.softAssertion(control.parts[trd_index], varpart3)
        
        print ('Done')
    

    def test_removePartFromPartHolder(self):