aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-12-01 18:20:54 +0100
committerMilo Casagrande <milo.casagrande@linaro.org>2014-12-01 18:20:54 +0100
commit001dfea2d1bea05b0d433e4d4381099adbb350ba (patch)
tree40e1768c524bbb731ded95f8394f0ca4ec97c88a /app/models
parente2605aa619872fd71b97a22a405a54fbde4c7477 (diff)
bisect: Add defconfig bisect data model.
Change-Id: I088ec91dfa9305ece6f8ff058d42e0520fefe680
Diffstat (limited to 'app/models')
-rw-r--r--app/models/__init__.py3
-rw-r--r--app/models/bisect.py21
-rw-r--r--app/models/tests/test_bisect_model.py33
3 files changed, 56 insertions, 1 deletions
diff --git a/app/models/__init__.py b/app/models/__init__.py
index 677fd0f..f527bf4 100644
--- a/app/models/__init__.py
+++ b/app/models/__init__.py
@@ -196,5 +196,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())