Skip to content

Commit af1cee8

Browse files
slurm: fix tests
Signed-off-by: Cecilia Lau <[email protected]>
1 parent a63dac9 commit af1cee8

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

coldfront/plugins/slurm/associations.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
parse_qos,
2626
)
2727

28-
SLURM_ACCOUNT_ATTRIBUTE_TYPE = AllocationAttributeType.objects.get(name=SLURM_ACCOUNT_ATTRIBUTE_NAME)
29-
3028
logger = logging.getLogger(__name__)
3129

3230

@@ -260,13 +258,16 @@ def add_allocation(self, allocation: Allocation, res_allocations: QuerySet[Alloc
260258
try:
261259
child_allocation = res_allocations.get(
262260
pk=AllocationAttribute.objects.get(
263-
allocation_attribute_type=SLURM_ACCOUNT_ATTRIBUTE_TYPE, value=account_name
261+
allocation_attribute_type=AllocationAttributeType.objects.get(
262+
name=SLURM_ACCOUNT_ATTRIBUTE_NAME
263+
),
264+
value=account_name,
264265
).allocation.pk
265266
)
266267
account.add_allocation(child_allocation, res_allocations, user_specs=user_specs)
267268
except ObjectDoesNotExist:
268269
raise SlurmError(
269-
f"No allocation with {SLURM_ACCOUNT_ATTRIBUTE_TYPE}={account_name} in correct resource" # Don't have an easy way to get the resource here
270+
f"No allocation with {SLURM_ACCOUNT_ATTRIBUTE_NAME}={account_name} in correct resource" # Don't have an easy way to get the resource here
270271
)
271272

272273
self.add_account(account)
File renamed without changes.

coldfront/plugins/slurm/tests/test_parents.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
from django.core.management import call_command
88
from django.test import TestCase
99

10-
from coldfront.core.allocation.models import Allocation, AllocationAttributeType
10+
from coldfront.core.allocation.models import Allocation
1111
from coldfront.core.resource.models import ResourceAttribute, ResourceAttributeType, ResourceType
1212
from coldfront.core.test_helpers.factories import (
1313
AllocationAttributeFactory,
14+
AllocationAttributeTypeFactory,
1415
AllocationStatusChoiceFactory,
1516
AllocationUserFactory,
1617
ProjectFactory,
@@ -22,6 +23,7 @@
2223

2324
# Building this account structure in slurm/coldfront
2425
# 'a' represents an account and 'u' represents a user
26+
# unless otherwise stated
2527
#
2628
# a1 a7
2729
# / \ / | \
@@ -37,8 +39,6 @@
3739
class AssociationTest(TestCase):
3840
@classmethod
3941
def setUpClass(cls):
40-
# call_command("import_field_of_science_data")
41-
# call_command("add_default_grant_options")
4242
call_command("add_default_project_choices")
4343
call_command("add_allocation_defaults")
4444
call_command("add_resource_defaults")
@@ -67,8 +67,8 @@ def setUpTestData(cls):
6767
ProjectUserFactory(project=cls.project, user=cls.u4)
6868
# create allocations
6969
alloc_kwargs = {"project": cls.project, "status": AllocationStatusChoiceFactory(name="Active")}
70-
san_aat = AllocationAttributeType.objects.get(name="slurm_account_name")
71-
sc_aat = AllocationAttributeType.objects.get(name="slurm_children")
70+
san_aat = AllocationAttributeTypeFactory(name="slurm_account_name")
71+
sc_aat = AllocationAttributeTypeFactory(name="slurm_children")
7272
cls.a1 = Allocation.objects.create(**alloc_kwargs)
7373
cls.a2 = Allocation.objects.create(**alloc_kwargs)
7474
cls.a3 = Allocation.objects.create(**alloc_kwargs)

0 commit comments

Comments
 (0)