def test_assignment_json_serde():
    asns = Assignments('test', 8, tp1, 12345, 1)
    jsonOut = asns.asJson()
    print(jsonOut)
    asnsDeser = Assignments.fromJson(jsonOut)

    assert asns.version == asnsDeser.version
    assert asns.group == asnsDeser.group
    assert asns.maxMembers == asnsDeser.maxMembers
    assert asns.configVersion == asnsDeser.configVersion
    assert len(asns.memberAssignments) == len(asnsDeser.memberAssignments)
    assert len(asns.topics) == len(asnsDeser.topics)
示例#2
0
 def _innerUpdateAssignment(self, assignment: Assignments):
     self._ensureAssignmentsPath()
     self.zk.set(self._assignmentsPath, assignment.asJson().encode('utf-8'))
     logger.info('Assignments updated. | assignments=%s', assignment)