forked from enviPath/enviPy
**This pull request will need a separate migration pull-request**
I have added an alert box in two places when the user tries to predict with stereo chemistry.
When a user predicts a pathway with stereo chemistry an alert box is shown in that node's hover.
To do this I added two new fields. Pathway now has a "predicted" BooleanField indicating whether it was predicted or not. It is set to True if the pathway mode for prediction is "predict" or "incremental" and False if it is "build". I think it is a flag that could be useful in the future, perhaps for analysing how many predicted pathways are in enviPath?
Node now has a `stereo_removed` BooleanField which is set to True if the Node's parent Pathways has "predicted" as true and the node SMILES has stereochemistry.
<img width="500" alt="{927AC9FF-DBC9-4A19-9E6E-0EDD3B08C7AC}.png" src="attachments/69ea29bc-c2d2-4cd2-8e98-aae5c5737f69">
When a user does a prediction on a model's page it shows at the top of the list. This did not require any new fields as the entered SMILES does not get saved anywhere.
<img width="500" alt="{BED66F12-5F07-419E-AAA6-FE1FE5B4F266}.png" src="attachments/5fcc3a9b-4d1a-4e48-acac-76b7571f6507">
I think the alert box is an alright solution but if you have a great idea for something that looks/fits better please change it or let me know.
Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#250
Co-authored-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
Co-committed-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
95 lines
3.1 KiB
Python
95 lines
3.1 KiB
Python
from django.conf import settings as s
|
|
from django.test import TestCase, override_settings
|
|
from django.urls import reverse
|
|
|
|
from epdb.logic import PackageManager
|
|
from epdb.models import Package, User
|
|
|
|
|
|
@override_settings(MODEL_DIR=s.FIXTURE_DIRS[0] / "models", CELERY_TASK_ALWAYS_EAGER=True)
|
|
class UserViewTest(TestCase):
|
|
fixtures = ["test_fixtures_incl_model.jsonl.gz"]
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(UserViewTest, cls).setUpClass()
|
|
cls.user = User.objects.get(username="anonymous")
|
|
cls.package = PackageManager.create_package(cls.user, "Anon Test Package", "No Desc")
|
|
cls.BBD_SUBSET = Package.objects.get(name="Fixtures")
|
|
|
|
def test_login_with_valid_credentials(self):
|
|
response = self.client.post(
|
|
reverse("login"),
|
|
{
|
|
"username": "user0",
|
|
"password": "SuperSafe",
|
|
},
|
|
)
|
|
self.assertRedirects(response, reverse("index"))
|
|
self.assertTrue(response.wsgi_request.user.is_authenticated)
|
|
|
|
def test_login_with_invalid_credentials(self):
|
|
response = self.client.post(
|
|
reverse("login"),
|
|
{
|
|
"username": "user0",
|
|
"password": "wrongpassword",
|
|
},
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertFalse(response.wsgi_request.user.is_authenticated)
|
|
|
|
def test_register(self):
|
|
response = self.client.post(
|
|
reverse("register"),
|
|
{
|
|
"username": "user1",
|
|
"email": "user1@envipath.com",
|
|
"password": "SuperSafe",
|
|
"rpassword": "SuperSafe",
|
|
},
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertContains(
|
|
response, "Your account has been created! An admin will activate it soon!"
|
|
)
|
|
|
|
def test_register_password_mismatch(self):
|
|
response = self.client.post(
|
|
reverse("register"),
|
|
{
|
|
"username": "user1",
|
|
"email": "user1@envipath.com",
|
|
"password": "SuperSafe",
|
|
"rpassword": "SuperSaf3",
|
|
},
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertContains(response, "Registration failed, provided passwords differ")
|
|
|
|
def test_logout(self):
|
|
response = self.client.post(
|
|
reverse("login"), {"username": "user0", "password": "SuperSafe", "login": "true"}
|
|
)
|
|
self.assertTrue(response.wsgi_request.user.is_authenticated)
|
|
|
|
response = self.client.post(
|
|
reverse("logout"),
|
|
{
|
|
"logout": "true",
|
|
},
|
|
)
|
|
self.assertFalse(response.wsgi_request.user.is_authenticated)
|
|
|
|
def test_next_param_properly_handled(self):
|
|
response = self.client.get(reverse("packages"))
|
|
|
|
self.assertRedirects(response, f"{reverse('login')}/?next=/package")
|
|
|
|
response = self.client.post(
|
|
reverse("login"),
|
|
{"username": "user0", "password": "SuperSafe", "login": "true", "next": "/package"},
|
|
)
|
|
|
|
self.assertRedirects(response, reverse("packages"))
|