def test_arrete_ministeriel(): am = ArreteMinisteriel( _str('Arrete du 01/01/10'), [_node_section()], [_enriched_string_links()], date(2010, 1, 1), 'aida', 'legifrance', classements=[Classement('1510', Regime.A, 'al')], classements_with_alineas=[ClassementWithAlineas('1510', Regime.A, ['al', 'albis'])], id='JORFTEXTid', ) dict_ = am.to_dict() new_dict = ArreteMinisteriel.from_dict(json.loads(json.dumps(dict_))).to_dict() assert new_dict == dict_
def upsert_am(self, am_id: str, am: ArreteMinisteriel) -> None: query = ( 'INSERT INTO structured_am(am_id, data) VALUES(%s, %s) ON CONFLICT (am_id)' ' DO UPDATE SET data = %s WHERE structured_am.am_id =%s;') data = json.dumps(am.to_dict()) self._exectute_update_query(query, (am_id, data, data, am_id))