def test_set_get_field_fields_container_new_label_default_value(): fc = FieldsContainer() fc.labels = ["time", "complex"] for i in range(0, 20): mscop = {"time": i + 1, "complex": 0} fc.add_field(mscop, Field(nentities=i + 10)) fc.add_label("shape", 3) for i in range(0, 20): mscop = {"time": i + 1, "complex": 0, "shape": 1} fc.add_field(mscop, Field(nentities=i + 10)) for i in range(0, 20): fieldid = fc.get_field({ "time": i + 1, "complex": 0, "shape": 1 })._message.id assert fieldid != 0 assert fc.get_field(i + 20)._message.id != 0 assert fc[i]._message.id != 0 assert fc.get_label_space(i + 20) == { "time": i + 1, "complex": 0, "shape": 1 } for i in range(0, 20): fieldid = fc.get_field({ "time": i + 1, "complex": 0, "shape": 3 })._message.id assert fieldid != 0 assert fc.get_field(i)._message.id != 0 assert fc[i]._message.id != 0 assert fc.get_label_space(i) == { "time": i + 1, "complex": 0, "shape": 3 }
def test_set_get_field_fields_container_new_label(): fc = FieldsContainer() fc.labels = ["time", "complex"] for i in range(0, 20): mscop = {"time": i + 1, "complex": 0} fc.add_field(mscop, Field(nentities=i + 10)) assert fc.get_available_ids_for_label() == list(range(1, 21)) for i in range(0, 20): fieldid = fc.get_field({"time": i + 1, "complex": 0})._message.id assert fieldid != 0 assert fc.get_field(i)._message.id != 0 assert (fc.get_field_by_time_complex_ids(timeid=i + 1, complexid=0)._message.id != 0) assert fc[i]._message.id != 0 assert fc.get_label_space(i) == {"time": i + 1, "complex": 0} fc.add_label("shape") for i in range(0, 20): mscop = {"time": i + 1, "complex": 0, "shape": 1} fc.add_field(mscop, Field(nentities=i + 10)) assert len(fc.get_fields({"time": i + 1, "complex": 0})) == 2 for i in range(0, 20): fieldid = fc.get_field({ "time": i + 1, "complex": 0, "shape": 1 })._message.id assert fieldid != 0 assert fc.get_field(i + 20)._message.id != 0 assert fc[i]._message.id != 0 assert fc.get_label_space(i + 20) == { "time": i + 1, "complex": 0, "shape": 1 }