1
0
Fork 0

projects_of_year test expanded, fails now (as expected)

This commit is contained in:
Benni Bärmann 2021-10-04 12:57:13 +02:00
parent 86d08db262
commit bef1f6d5ae
2 changed files with 9 additions and 0 deletions

View File

@ -98,6 +98,12 @@ class Project(Volunteer):
# self.finance_id = "1234000" # self.finance_id = "1234000"
year = self.start.year year = self.start.year
print(f"startyear: {year}") print(f"startyear: {year}")
projects = Project.objects.filter(start__year=year)
print(projects)
if not projects:
self.project_of_year = 1
else:
pass
else: else:
print(f"project_of_year is {self.project_of_year}") print(f"project_of_year is {self.project_of_year}")
super().save(*args,**kwargs) super().save(*args,**kwargs)

View File

@ -54,3 +54,6 @@ class TestWithLogin(TestCase):
#obj.save() #obj.save()
print(f'pid: {obj.project_of_year}') print(f'pid: {obj.project_of_year}')
self.assertEqual(obj.project_of_year,1) self.assertEqual(obj.project_of_year,1)
obj2 = Project.objects.create(account= acc, name='testproject2', start=startdate)
self.assertEqual(obj.project_of_year,2)