def METHOD_NAME(self):
    # create a few date ranges
    date_range_type = self.env["date.range.type"].create(dict(name="Year"))
    for year in (2016, 2017, 2018):
        self.env["date.range"].create(
            dict(
                type_id=date_range_type.id,
                name="%d" % year,
                date_start="%d-01-01" % year,
                date_end="%d-12-31" % year,
                company_id=False,
            )
        )
    self.instance.write(dict(comparison_mode=True, date="2017-06-15"))
    self.period.write(
        dict(
            mode=MODE_REL,
            type="date_range",
            date_range_type_id=date_range_type.id,
            offset="-1",
            duration=3,
        )
    )
    self.assertDateEqual(self.period.date_from, "2016-01-01")
    self.assertDateEqual(self.period.date_to, "2018-12-31")
    self.assertTrue(self.period.valid)