def test_set_name_setter(self):
        test_suite = mtsuite.TestSuiteDocument("name", "lab_name", "build_id",
                                               "1.0")

        def test_name_setter(value):
            test_suite.name = value

        test_name_setter("foo")
        self.assertEqual("foo", test_suite.name)
    def test_suite_doc_to_dict(self):
        test_suite = mtsuite.TestSuiteDocument("name", "lab_name", "build_id",
                                               "1.0")

        test_suite.arch = "arm"
        test_suite.board = "board"
        test_suite.board_instance = 1
        test_suite.boot_id = "boot_id"
        test_suite.created_on = "now"
        test_suite.defconfig = "defconfig"
        test_suite.build_id = "another_build-id"
        test_suite.definition_uri = "uri"
        test_suite.git_branch = "git_branch"
        test_suite.id = "id"
        test_suite.job = "job"
        test_suite.job_id = "job_id"
        test_suite.kernel = "kernel"
        test_suite.lab_name = "another_lab"
        test_suite.metadata = {"foo": "bar"}
        test_suite.test_case = ["foo"]
        test_suite.test_set = ["bar"]
        test_suite.time = 10
        test_suite.vcs_commit = "1234"
        test_suite.version = "1.1"

        expected = {
            "_id": "id",
            "arch": "arm",
            "board": "board",
            "board_instance": 1,
            "boot_id": "boot_id",
            "created_on": "now",
            "defconfig": "defconfig",
            "defconfig_full": "defconfig",
            "build_id": "another_build-id",
            "definition_uri": "uri",
            "git_branch": "git_branch",
            "job": "job",
            "job_id": "job_id",
            "kernel": "kernel",
            "lab_name": "another_lab",
            "metadata": {
                "foo": "bar"
            },
            "name": "name",
            "test_case": ["foo"],
            "test_set": ["bar"],
            "time": 10,
            "vcs_commit": "1234",
            "version": "1.1"
        }

        self.assertDictEqual(expected, test_suite.to_dict())
Exemplo n.º 3
0
        err_msg = "Missing mandatory key in test suite data"
        utils.LOG.exception(ex)
        utils.LOG.error(err_msg)
        ERR_ADD(errors, 400, err_msg)
        return None

    arch = test_json.get(models.ARCHITECTURE_KEY, models.ARM_ARCHITECTURE_KEY)

    if arch not in models.VALID_ARCHITECTURES:
        err_msg = "Invalid architecture found: %s".format(arch)
        utils.LOG.error(err_msg)
        ERR_ADD(errors, 400, err_msg)
        return None

    test_doc = mtest_suite.TestSuiteDocument(
        name=name,
        lab_name=lab_name)
    test_doc.created_on = datetime.datetime.now(
        tz=bson.tz_util.utc)
    _update_test_suite_doc_from_json(test_doc, test_json, errors)
    _update_test_suite_doc_ids(test_doc, database)
    return test_doc


def import_and_save_test_sets(test_cases, test_sets,
                              tsu_id, tsu_name,
                              database, errors):
    """Parse the test set report from a JSON object.

    This function parses the test cases reports to find the distinct
    test set names. It creates database entries for each unique set name.
 def test_suite_doc_valid_instance(self):
     test_suite = mtsuite.TestSuiteDocument("name", "lab_name", "build_id",
                                            "1.0")
     self.assertIsInstance(test_suite, mbase.BaseDocument)