def test_lt(): fete1 = fete_base() autrefete = adjutoria.Fete() autrefete.degre = 3 autrefete._priorite = 550 assert fete1.__lt__(autrefete) autrefete.degre = 1 assert fete1.__lt__(autrefete)
def test_hash(): fete = adjutoria.Fete() hache = hash(fete) attr_dict = fete.__dict__.copy() assert not (attr_dict is fete.__dict__) del (attr_dict['parent']) attr_dict['personne'] = str(attr_dict['personne']) assert hash(fete) == hache == hash(json.dumps(attr_dict, sort_keys=True)) fete.parent = 1 assert hash(fete) == hache == hash(json.dumps(attr_dict, sort_keys=True))
def test_temps_liturgique(): fete = fete_base() assert fete.temps_liturgique() == 'Sometimes' fete._temps_liturgique = 'variable' fete.date = datetime.date(1962, 1, 1) fete.parent = mock.MagicMock() fete2 = adjutoria.Fete() fete2.temporal = True fete2._temps_liturgique = 'A time' fete.parent.__getitem__.return_value = [fete2] assert fete.temps_liturgique() == fete2._temps_liturgique assert mock.call(fete.date) in fete.parent.__getitem__.call_args_list assert fete.parent.__getitem__.call_count == 1
def test_weeknumber(): fete = adjutoria.Fete() fete.date = datetime.date(2015, 1, 1) assert fete.weeknumber() == 1 and fete.weeknumber(month=False, year=True) == 1 assert fete.weeknumber(month=False, year=False) == fete.weeknumber( month=True, year=True) == (1, 1) fete.date = datetime.date(2016, 1, 1) assert fete.weeknumber() == 1 and fete.weeknumber(month=False, year=True) == 0 assert fete.weeknumber(month=False, year=False) == fete.weeknumber( month=True, year=True) == (1, 0) fete.date = datetime.date(2000, 12, 31) assert fete.weeknumber(month=False, year=True) == 53 for day in (10, 11, 12, 13, 14, 15, 16): fete.date = datetime.date(2016, 1, day) assert fete.weeknumber() == 3 fete.date = datetime.date(2017, 1, 1) assert fete.weeknumber(year=True) == (1, 1) fete.date = datetime.date(2022, 1, 1) assert fete.weeknumber(year=True) == (1, 0)
def fete_base(): fete1 = adjutoria.Fete() fete1.degre = 1 fete1._priorite = 1800 fete1._temps_liturgique = 'Sometimes' return fete1