|
82 | 82 |
|
83 | 83 | if len(matching_flows) == 0:
|
84 | 84 | raise KeyError("Requested flow not found on RapidPro (Available flows: {})".format(
|
85 |
| - ",".join(list(map(lambda f: f.name, flows))))) |
| 85 | + ", ".join(list(map(lambda f: f.name, flows))))) |
86 | 86 | if len(matching_flows) > 1:
|
87 | 87 | raise KeyError("Non-unique flow name")
|
88 | 88 |
|
|
117 | 117 | # Sometimes contact uuids which appear in `runs` do not appear in `contact_runs`.
|
118 | 118 | # I have only observed this happen for contacts which were created very recently.
|
119 | 119 | # This test skips the run in this case; it should be included next time this script is executed.
|
120 |
| - print("Warning: Run found with uuid '{}', but this id is not present in contacts".format(run.contact.uuid)) |
| 120 | + print(f"Warning: Run found with Rapid Pro Contact UUID '{run.contact.uuid}', " |
| 121 | + f"but this id is not present in the downloaded contacts") |
121 | 122 | continue
|
122 | 123 |
|
123 | 124 | contact_urns = contact_runs[run.contact.uuid].urns
|
124 | 125 |
|
125 | 126 | if len(contact_urns) == 0:
|
126 |
| - print("Warning: Ignoring contact with no urn. URNs: {}, UUID: {}".format(contact_urns, run.contact.uuid)) |
| 127 | + print(f"Warning: Ignoring contact with no urn. URNs: {contact_urns} " |
| 128 | + f"(Rapid Pro Contact UUID: {run.contact.uuid})") |
127 | 129 | continue
|
128 | 130 |
|
129 |
| - # assert len(contact_urns) == 1, "Contact has multiple URNs" TODO: Re-enable once AVF test runs are ignored. |
130 |
| - run_dict = {"avf_phone_id": phone_uuids.add_phone(contact_urns[0])} |
| 131 | + run_dict = { |
| 132 | + "avf_phone_id": phone_uuids.add_phone(contact_urns[0]), |
| 133 | + f"run_id - {run.flow.name}": run.id |
| 134 | + } |
131 | 135 |
|
132 | 136 | for category, response in run.values.items():
|
133 | 137 | run_dict[category.title() + " (Category) - " + run.flow.name] = response.category
|
|
140 | 144 |
|
141 | 145 | if run.contact.uuid in test_contacts:
|
142 | 146 | run_dict["test_run"] = True
|
| 147 | + else: |
| 148 | + assert len(contact_urns) == 1, \ |
| 149 | + f"A non-test contact has multiple URNs (Rapid Pro Contact UUID: {run.contact.uuid})" |
143 | 150 |
|
144 | 151 | if mode == "all":
|
145 | 152 | run_dict["created_on"] = run.created_on.isoformat()
|
|
0 commit comments