def test_serialize_copr_build(): b = CoprBuild.create("foo", "bar", ["a", "b"], save=False) s = b.serialize() assert s["project"] == "foo" assert s["owner"] == "bar" assert s["chroots"] == ["a", "b"] nb = CoprBuild() nb.deserialize(s) assert nb.project == "foo" assert nb.owner == "bar" assert nb.chroots == ["a", "b"]
def copr_build_model(self) -> RedisCoprBuild: if self._copr_build_model is None: self._copr_build_model = RedisCoprBuild.create( project=self.job_project, owner=self.job_owner, chroots=self.build_chroots, ) return self._copr_build_model
def get(self): """ List all Copr builds. From 'copr-builds' hash, filled by service. """ # I know it's expensive to first convert whole dict to a list and then slice the list, # but how else would you slice a dict, huh? result = [] for k, cb in CoprBuild.db().get_all().items(): if k == LAST_PK: # made-up keys, remove LAST_PK continue cb.pop("identifier", None) # see PR#179 result.append(cb) first, last = indices() resp = make_response(dumps(result[first:last]), HTTPStatus.PARTIAL_CONTENT) resp.headers[ "Content-Range"] = f"copr-builds {first + 1}-{last}/{len(result)}" resp.headers["Content-Type"] = "application/json" return resp