import unittest
import utils

all_files = [
    "core/mini_modify.alc",
    "core/core_formalism.mvc",
    "core/core_algorithm.alc",
    "primitives.alc",
    "object_operations.alc",
    "conformance_scd.alc",
    "library.alc",
    "transform.alc",
    "model_management.alc",
    "ramify.alc",
    "metamodels.alc",
    "random.alc",
    "constructors.alc",
    "modelling.alc",
    "compilation_manager.alc",
]


class TestMvCModelOverwrite(unittest.TestCase):
    def model_overwrite(self, optimization_level):
        utils.write_total_runtime_to_file(
            'mvc_model_overwrite', optimization_level,
            utils.run_correctness_test(all_files, [
                "root",
                "root",
                "root",
                "model_add",
                "SimpleClassDiagrams",
                "Empty",
                "exit",
                "model_list_full",
                "model_modify",
                "Empty",
                "instantiate",
                "Class",
                "A",
                "exit",
                "model_list_full",
                "model_overwrite",
                "Empty",
                "instantiate_node",
                "",
                "Class",
                "B",
                "instantiate_node",
                "",
                "Class",
                "C",
                "exit",
                "model_list_full",
                "model_modify",
                "Empty",
                "list",
                "exit",
            ], [
                "Desired username for admin user?",
                "Desired password for admin user?",
                "Please repeat the password",
                "Passwords match!",
                "Welcome to the Model Management Interface v2.0!",
                "Use the 'help' command for a list of possible commands",
                "Ready for command...",
                "Creating new model!",
                "Model type?",
                "Model name?",
                "Waiting for model constructors...",
                "Model upload success!",
                "Ready for command...",
                set([
                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                    "  200  root nobody   Empty : SimpleClassDiagrams",
                    "  200  root admin   core : CoreFormalism"
                ]),
                "Ready for command...",
                "Which model do you want to modify?",
                "Model loaded, ready for commands!",
                "Use 'help' command for a list of possible commands",
                "Please give your command.",
                "Type to instantiate?",
                "Name of new element?",
                "Instantiation successful!",
                "Please give your command.",
                "Ready for command...",
                set([
                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                    "  200  root nobody   Empty : SimpleClassDiagrams",
                    "  200  root admin   core : CoreFormalism"
                ]),
                "Ready for command...",
                "Which model to overwrite?",
                "Waiting for model constructors...",
                "Model overwrite success!",
                "Ready for command...",
                set([
                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                    "  200  root nobody   Empty : SimpleClassDiagrams",
                    "  200  root admin   core : CoreFormalism"
                ]),
                "Ready for command...",
                "Which model do you want to modify?",
                "Model loaded, ready for commands!",
                "Use 'help' command for a list of possible commands",
                "Please give your command.",
                "List of all elements:",
                set(["  B : Class", "  C : Class"]),
                "Please give your command.",
                "Ready for command...",
            ], optimization_level))


utils.define_perf_tests(TestMvCModelOverwrite,
                        TestMvCModelOverwrite.model_overwrite)
