-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from HiSPARC/testing-updates
Improve lint tests
- Loading branch information
Showing
57 changed files
with
752 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
.PHONY: devinstall test unittests coveragetests flaketest doctest ansibletest | ||
|
||
.PHONY: devinstall | ||
devinstall: | ||
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt | ||
conda install --quiet --yes --channel conda-forge --file provisioning/roles/publicdb/files/requirements-conda.txt | ||
pip install -r provisioning/roles/publicdb/files/requirements-pip.txt | ||
|
||
test: coveragetests flaketest doctest ansibletest | ||
.PHONY: test | ||
test: coveragetests linttest doctest ansibletest | ||
|
||
.PHONY: unittests | ||
unittests: | ||
coverage run ./manage.py test $(tests) | ||
|
||
.PHONY: coveragetests | ||
coveragetests: unittests | ||
coverage report | ||
|
||
flaketest: | ||
flake8 | ||
.PHONY: linttest | ||
linttest: | ||
ruff check . | ||
typos . | ||
|
||
.PHONY: doctest | ||
doctest: | ||
PYTHONPATH=$(CURDIR):$(PYTHONPATH) sphinx-build -anW doc doc/_build/html | ||
|
||
.PHONY: ansibletest | ||
ansibletest: | ||
ansible-lint -p provisioning/playbook.yml || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,35 +26,35 @@ class AnalysisSession(models.Model): | |
starts = models.DateTimeField() | ||
ends = models.DateTimeField() | ||
|
||
def in_progress(self): | ||
return self.starts <= datetime.datetime.now() < self.ends | ||
class Meta: | ||
verbose_name = 'Analysis session' | ||
verbose_name_plural = 'Analysis sessions' | ||
|
||
in_progress.boolean = True | ||
def __str__(self): | ||
return self.title | ||
|
||
def save(self, *args, **kwargs): | ||
self.hash = hashlib.md5(self.slug.encode('utf-8')).hexdigest() | ||
super().save(*args, **kwargs) | ||
Student(session=self, name='Test student').save() | ||
|
||
def __str__(self): | ||
return self.title | ||
def in_progress(self): | ||
return self.starts <= datetime.datetime.now() < self.ends | ||
|
||
class Meta: | ||
verbose_name = 'Analysis session' | ||
verbose_name_plural = 'Analysis sessions' | ||
in_progress.boolean = True | ||
|
||
|
||
class Student(models.Model): | ||
session = models.ForeignKey(AnalysisSession, models.CASCADE, related_name='students') | ||
name = models.CharField(max_length=255) | ||
|
||
def __str__(self): | ||
return f'{self.session} - {self.name}' | ||
|
||
class Meta: | ||
verbose_name = 'Student' | ||
verbose_name_plural = 'Students' | ||
|
||
def __str__(self): | ||
return f'{self.session} - {self.name}' | ||
|
||
|
||
class AnalyzedCoincidence(models.Model): | ||
session = models.ForeignKey(AnalysisSession, models.CASCADE, related_name='analyzed_coincidences') | ||
|
@@ -68,14 +68,14 @@ class AnalyzedCoincidence(models.Model): | |
phi = models.FloatField(null=True, blank=True) | ||
error_estimate = models.FloatField(null=True, blank=True) | ||
|
||
def __str__(self): | ||
return f"{self.coincidence} - {self.student}" | ||
|
||
class Meta: | ||
verbose_name = 'Analyzed coincidence' | ||
verbose_name_plural = 'Analyzed coincidences' | ||
ordering = ['coincidence'] | ||
|
||
def __str__(self): | ||
return f'{self.coincidence} - {self.student}' | ||
|
||
|
||
class SessionRequest(models.Model): | ||
first_name = models.CharField(max_length=255) | ||
|
@@ -100,7 +100,7 @@ class Meta: | |
|
||
@property | ||
def name(self): | ||
return f"{self.first_name} {self.sur_name}" | ||
return f'{self.first_name} {self.sur_name}' | ||
|
||
def create_session(self): | ||
self.session_pending = False | ||
|
@@ -157,7 +157,7 @@ def find_coincidence(self, date, session): | |
all_coincidences = cq.any(stations) | ||
coincidences = cq.events_from_stations(all_coincidences, stations, n=3) | ||
for coincidence in coincidences: | ||
# Todo: Double check for multiple events from same station, | ||
# TODO: Double check for multiple events from same station, | ||
self.save_coincidence(coincidence, session) | ||
number_of_coincidences += 1 | ||
|
||
|
@@ -212,14 +212,14 @@ def generate_url(self): | |
def sendmail_request(self): | ||
subject = 'HiSPARC analysis session request' | ||
message = textwrap.dedent( | ||
f'''\ | ||
f"""\ | ||
Hello {self.name}, | ||
Please click on this link to confirm your request for an analysis session with jSparc: | ||
https://data.hisparc.nl/analysis-session/request/{self.url}/ | ||
Greetings, | ||
The HiSPARC Team''' | ||
The HiSPARC Team""", | ||
) | ||
sender = 'Beheer HiSPARC <[email protected]>' | ||
send_mail(subject, message, sender, [self.email], fail_silently=False) | ||
|
@@ -229,7 +229,7 @@ def sendmail_request(self): | |
def sendmail_created(self): | ||
subject = 'HiSPARC analysis session created' | ||
message = textwrap.dedent( | ||
f'''\ | ||
f"""\ | ||
Hello {self.name}, | ||
Your analysis session for jSparc has been created. | ||
|
@@ -244,15 +244,15 @@ def sendmail_created(self): | |
https://data.hisparc.nl/analysis-session/{slugify(self.sid)}/data/ | ||
Greetings, | ||
The HiSPARC Team''' | ||
The HiSPARC Team""", | ||
) | ||
sender = 'Beheer HiSPARC <[email protected]>' | ||
send_mail(subject, message, sender, [self.email], fail_silently=False) | ||
|
||
def sendmail_created_less(self): | ||
subject = 'HiSPARC analysis session created with less events' | ||
message = textwrap.dedent( | ||
f'''\ | ||
f"""\ | ||
Hello {self.name}, | ||
Your analysis session for jSparc has been created. | ||
|
@@ -269,23 +269,23 @@ def sendmail_created_less(self): | |
https://data.hisparc.nl/analysis-session/{slugify(self.sid)}/data/ | ||
Greetings, | ||
The HiSPARC Team''' | ||
The HiSPARC Team""", | ||
) | ||
sender = 'Beheer HiSPARC <[email protected]>' | ||
send_mail(subject, message, sender, [self.email], fail_silently=False) | ||
|
||
def sendmail_zero(self): | ||
subject = 'HiSPARC analysis session creation failed' | ||
message = textwrap.dedent( | ||
f'''\ | ||
f"""\ | ||
Hello {self.name}, | ||
Your analysis session for jSparc could not be created. | ||
Perhaps there was no data for the date and/or stations you selected. | ||
Please try selecting a different cluster or date. | ||
Greetings, | ||
The HiSPARC Team''' | ||
The HiSPARC Team""", | ||
) | ||
sender = 'Beheer HiSPARC <[email protected]>' | ||
send_mail(subject, message, sender, [self.email], fail_silently=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.