Page MenuHomekolab.org

Race between Todo and Event to_dict()
Closed, ResolvedPublic

Description

When executing todo tests before event tests, which is when you call nosetests ./tests/unit to_dict() on an Event object does not return all properties, i.e. it works using properties_map variable from Todo class.

This causes one test to fail when calling only event tests (nosetests ./tests/unit/test-003-event.py). Actually the test fails because there's a bug in the test itself, probably not found before because no one run it separately.

def test_026_compute_diff(self):
        e1 = event_from_string(xml_event)
        e2 = event_from_string(xml_event)

        e2.set_summary("test2")
        e2.set_end(e1.get_end() + datetime.timedelta(hours=3))
        e2.set_sequence(e1.get_sequence() + 1)
        e2.set_attendee_participant_status("jane@example.org", "DECLINED")
        e2.set_lastmodified()

        diff = compute_diff(e1.to_dict(), e2.to_dict(), True)
        self.assertEqual(len(diff), 4, "Diff: (length: %d):\r\n%r\r\n%r" % (len(diff), diff, e2.__str__()))

The diff list contains (and should contain) 5 elements (as you see, we modified 5 properties of the event), so 4 in the assert should be changed to 5. In this case to_dict() does not see 'end' property when executing all scripts, but sees it when executing event tests only.

I have no idea why to_dict() behaves like that. I confirmed that e1 and e2 are of type Event.