Skip to content

Commit

Permalink
Add manage.py validation check
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Nov 21, 2024
1 parent 4171f6b commit 6b866aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arches/app/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

IntegrityCheckDescriptions = {
1005: "Nodes with ontologies found in graphs without ontologies",
1012: "Node Groups without matching nodes",
1012: "Node Groups without contained nodes",
1013: "Node Groups without a root node",
}


@unique
class IntegrityCheck(Enum):
NODE_HAS_ONTOLOGY_GRAPH_DOES_NOT = 1005
NODELESS_NODE_GROUP = 1012
NODEGROUP_WITHOUT_ROOT_NODE = 1013

def __str__(self):
return IntegrityCheckDescriptions[self.value]
Expand Down
5 changes: 5 additions & 0 deletions arches/management/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def handle(self, *args, **options):
),
fix_action=DELETE_QUERYSET,
)
self.check_integrity(
check=IntegrityCheck.NODEGROUP_WITHOUT_ROOT_NODE, # 1013
queryset=models.NodeGroup.objects.filter(node__gt=0, root_node=None),
fix_action=None,
)

def check_integrity(self, check, queryset, fix_action):
# 500 not set as a default earlier: None distinguishes whether verbose output implied
Expand Down

0 comments on commit 6b866aa

Please sign in to comment.