diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/__init__.py | 3 | ||||
-rw-r--r-- | app/models/bisect.py | 21 | ||||
-rw-r--r-- | app/models/tests/test_bisect_model.py | 33 |
3 files changed, 56 insertions, 1 deletions
diff --git a/app/models/__init__.py b/app/models/__init__.py index de1c0fc..55b4ff9 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -198,5 +198,6 @@ VALID_JOB_STATUS = [ # The valid collections for the bisect handler. BISECT_VALID_COLLECTIONS = [ - BOOT_COLLECTION + BOOT_COLLECTION, + DEFCONFIG_COLLECTION, ] diff --git a/app/models/bisect.py b/app/models/bisect.py index a05cc43..4d8d8e9 100644 --- a/app/models/bisect.py +++ b/app/models/bisect.py @@ -135,3 +135,24 @@ class BootBisectDocument(BisectDocument): boot_b_dict[models.DEFCONFIG_ID_KEY] = self.defconfig_id boot_b_dict[models.BOOT_ID_KEY] = self.boot_id return boot_b_dict + + +class DefconfigBisectDocument(BisectDocument): + """The bisect document class for defconfig/build bisection.""" + + def __init__(self, name): + super(DefconfigBisectDocument, self).__init__(name) + + self.defconfig = None + self.defconfig_id = None + self.defconfig_full = None + self.arch = None + + def to_dict(self): + def_b_dict = super(DefconfigBisectDocument, self).to_dict() + def_b_dict[models.DEFCONFIG_ID_KEY] = self.defconfig_id + def_b_dict[models.DEFCONFIG_KEY] = self.defconfig + def_b_dict[models.DEFCONFIG_FULL_KEY] = self.defconfig_full + def_b_dict[models.ARCHITECTURE_KEY] = self.arch + + return def_b_dict diff --git a/app/models/tests/test_bisect_model.py b/app/models/tests/test_bisect_model.py index 3cc1b9b..874835b 100644 --- a/app/models/tests/test_bisect_model.py +++ b/app/models/tests/test_bisect_model.py @@ -135,3 +135,36 @@ class TestBisectModel(unittest.TestCase): bisect_doc.board = "bar" self.assertEqual(bisect_doc.board, "bar") + + def test_bisect_defconfig_to_dict(self): + bisect_doc = modbs.DefconfigBisectDocument("foo") + bisect_doc.id = "bar" + bisect_doc.defconfig_id = "defconfig-id" + bisect_doc.defconfig = "defconfig-name" + bisect_doc.version = "1.0" + bisect_doc.job = "job" + bisect_doc.job_id = "job-id" + bisect_doc.defconfig_full = "defconfig-full" + bisect_doc.arch = "arm" + + expected = { + "_id": "bar", + "created_on": None, + "job": "job", + "name": "foo", + "bisect_data": [], + "good_commit": None, + "good_commit_date": None, + "good_commit_url": None, + "bad_commit": None, + "bad_commit_date": None, + "bad_commit_url": None, + "version": "1.0", + "defconfig_id": "defconfig-id", + "defconfig": "defconfig-name", + "job_id": "job-id", + "defconfig_full": "defconfig-full", + "arch": "arm" + } + + self.assertDictEqual(expected, bisect_doc.to_dict()) |