mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-02-24 09:01:18 +00:00
Compare commits
2 Commits
9930c48253
...
5bf6a5501d
Author | SHA1 | Date | |
---|---|---|---|
5bf6a5501d | |||
9523b5f05f |
@ -47,7 +47,13 @@ class WEISurveyForm2021(forms.Form):
|
|||||||
words = []
|
words = []
|
||||||
for _ignored in range(information.step + 1):
|
for _ignored in range(information.step + 1):
|
||||||
# Generate N times words
|
# Generate N times words
|
||||||
words = [rng.choice(WORDS) for _ignored2 in range(10)]
|
words = None
|
||||||
|
preferred_words = {bus: [word for word in WORDS if WEIBusInformation2021(bus).scores[word] >= 50]
|
||||||
|
for bus in WEISurveyAlgorithm2021.get_buses()}
|
||||||
|
while words is None or len(set(words)) != len(words):
|
||||||
|
# Ensure that there is no the same word 2 times
|
||||||
|
words = [rng.choice(words) for _ignored2, words in preferred_words.items()]
|
||||||
|
rng.shuffle(words)
|
||||||
words = [(w, w) for w in words]
|
words = [(w, w) for w in words]
|
||||||
if self.data:
|
if self.data:
|
||||||
self.fields["word"].choices = [(w, w) for w in WORDS]
|
self.fields["word"].choices = [(w, w) for w in WORDS]
|
||||||
|
@ -84,6 +84,13 @@ class TestWEIRegistration(TestCase):
|
|||||||
wei=self.wei,
|
wei=self.wei,
|
||||||
description="Test Bus",
|
description="Test Bus",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Setup the bus
|
||||||
|
bus_info = CurrentSurvey.get_algorithm_class().get_bus_information(self.bus)
|
||||||
|
bus_info.scores["Jus de fruit"] = 70
|
||||||
|
bus_info.save()
|
||||||
|
self.bus.save()
|
||||||
|
|
||||||
self.team = BusTeam.objects.create(
|
self.team = BusTeam.objects.create(
|
||||||
name="Test Team",
|
name="Test Team",
|
||||||
bus=self.bus,
|
bus=self.bus,
|
||||||
@ -761,58 +768,6 @@ class TestDefaultWEISurvey(TestCase):
|
|||||||
self.assertEqual(CurrentSurvey.get_year(), 2021)
|
self.assertEqual(CurrentSurvey.get_year(), 2021)
|
||||||
|
|
||||||
|
|
||||||
class TestWEISurveyAlgorithm(TestCase):
|
|
||||||
"""
|
|
||||||
Run the WEI Algorithm.
|
|
||||||
TODO: Improve this test with some test data once the algorithm will be implemented.
|
|
||||||
"""
|
|
||||||
fixtures = ("initial",)
|
|
||||||
|
|
||||||
def setUp(self) -> None:
|
|
||||||
self.year = timezone.now().year
|
|
||||||
self.wei = WEIClub.objects.create(
|
|
||||||
name="Test WEI",
|
|
||||||
email="gc.wei@example.com",
|
|
||||||
parent_club_id=2,
|
|
||||||
membership_fee_paid=12500,
|
|
||||||
membership_fee_unpaid=5500,
|
|
||||||
membership_start=date(self.year, 1, 1),
|
|
||||||
membership_end=date(self.year, 12, 31),
|
|
||||||
year=self.year,
|
|
||||||
date_start=date.today() + timedelta(days=2),
|
|
||||||
date_end=date(self.year, 12, 31),
|
|
||||||
)
|
|
||||||
NoteClub.objects.create(club=self.wei)
|
|
||||||
self.bus = Bus.objects.create(
|
|
||||||
name="Test Bus",
|
|
||||||
wei=self.wei,
|
|
||||||
description="Test Bus",
|
|
||||||
)
|
|
||||||
self.team = BusTeam.objects.create(
|
|
||||||
name="Test Team",
|
|
||||||
bus=self.bus,
|
|
||||||
color=0xFFFFFF,
|
|
||||||
description="Test Team",
|
|
||||||
)
|
|
||||||
|
|
||||||
self.user = User.objects.create(username="toto")
|
|
||||||
self.registration = WEIRegistration.objects.create(
|
|
||||||
user_id=self.user.id,
|
|
||||||
wei_id=self.wei.id,
|
|
||||||
soge_credit=True,
|
|
||||||
caution_check=True,
|
|
||||||
birth_date=date(2000, 1, 1),
|
|
||||||
gender="nonbinary",
|
|
||||||
clothing_cut="male",
|
|
||||||
clothing_size="XL",
|
|
||||||
health_issues="I am a bot",
|
|
||||||
emergency_contact_name="Pikachu",
|
|
||||||
emergency_contact_phone="+33123456789",
|
|
||||||
first_year=True,
|
|
||||||
)
|
|
||||||
CurrentSurvey(self.registration).save()
|
|
||||||
|
|
||||||
|
|
||||||
class TestWeiAPI(TestAPI):
|
class TestWeiAPI(TestAPI):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user