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 TestMvCPrintUpload(unittest.TestCase):
    def print_upload(self, optimization_level):
        utils.write_total_runtime_to_file(
            'mvc_print_upload', optimization_level,
            utils.run_correctness_test(all_files, [
                "root",
                "root",
                "root",
                "model_add",
                "SimpleClassDiagrams",
                "PetriNets",
            ] + utils.get_model_constructor(
                open("integration/code/pn_runtime.mvc", "r").read()
            ) + [
                "model_list_full",
                "transformation_add_MT_language",
                "PetriNets",
                "",
                "PetriNets_RAM",
                "model_list_full",
                "transformation_add_MT",
                "PetriNets_RAM",
                "PetriNets",
                "",
                "",
                "PetriNets_Print",
            ] + utils.get_model_constructor(
                open("integration/code/pn_print.mvc", "r").read()
            ) + [
                "transformation_list_full",
            ], [
                "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   PetriNets : SimpleClassDiagrams",
                    "  200  root admin   core : CoreFormalism"
                ]),
                "Ready for command...",
                "Formalisms to include (terminate with empty string)?",
                "Name of the RAMified transformation metamodel?",
                "Ready for command...",
                set([
                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                    "  200  root nobody   PetriNets : SimpleClassDiagrams",
                    "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
                    "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
                    "  200  root admin   core : CoreFormalism"
                ]),
                "Ready for command...",
                "RAMified metamodel to use?",
                "Supported metamodels:",
                set([
                    "  PetriNets",
                ]),
                "",
                "Which ones do you want to use as source (empty string to finish)?",
                "Model added as source",
                "Which ones do you want to use as target (empty string to finish)?",
                "Name of new transformation?",
                "Waiting for model constructors...",
                "Ready for command...",
                set([
                    "  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                ]),
                "Ready for command...",
            ], optimization_level))


utils.define_perf_tests(TestMvCPrintUpload, TestMvCPrintUpload.print_upload)
