The Socialist party's remarkable move from outsider critic to occupant of City Hall