Skip to content

Commit

Permalink
fix is_nex_data again and test for pf media
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Jan 12, 2024
1 parent f2057b1 commit fb9bde9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/gn_modulator/schema/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ def is_new_data(self, model, data):
for key, data_value in data.items():
if not hasattr(model, key):
continue
fields = [key]
fields = []
if self.is_relation_1_n(key) or self.is_relation_n_n(key):
fields = []
for item in data_value:
for k in item:
kk = f"{key}.{k}"
if kk not in fields and self.has_property(kk):
fields.append(kk)
if len(fields) == 0:
fields = [key]

m_ = self.serialize(model, fields=fields)
m = m_[key]
if self.is_new_data(m, data_value):
Expand Down
11 changes: 11 additions & 0 deletions backend/gn_modulator/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def test_repo_diag(self, users, passages_faune_with_diagnostic):

assert True

def test_repo_pf_update(self, passages_faune_with_diagnostic):
sm = SchemaMethods("m_sipaf.pf")

uuid_pf = passages_faune_with_diagnostic[0].uuid_passage_faune
fields = ["id_passage_faune", "uuid_passage_faune", "medias"]
q = sm.get_row(uuid_pf, "uuid_passage_faune", "R", params={"fields": fields})
m = q.one()
data = sm.serialize(m, fields)
assert sm.is_new_data(m, data) is False
sm.update_row(uuid_pf, data, "uuid_passage_faune", "m_sipaf")

def test_repo_diag_cloture(self, passages_faune_with_diagnostic):
sm = SchemaMethods("m_sipaf.diag")
sm_org = SchemaMethods("user.organisme")
Expand Down

0 comments on commit fb9bde9

Please sign in to comment.