Skip to content

Commit

Permalink
Merge pull request #91 from ProteinsWebTeam/dev
Browse files Browse the repository at this point in the history
RC 1.8.0
  • Loading branch information
gustavo-salazar authored Oct 5, 2022
2 parents 3d860dd + 781ff20 commit 371c14f
Show file tree
Hide file tree
Showing 37 changed files with 597 additions and 331 deletions.
29 changes: 22 additions & 7 deletions deploy_tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,35 @@ Assume we have a user account at /home/username

## Testing

* The unit tests are located in ```[project]/source/webfront/tests/tests.py```
The unit tests are located in `[project]/source/webfront/tests/`.

To run unit tests use ```../virtualenv/bin/python manage.py test webfront```
To run unit tests use

* The functional test are in ```[project]/functional_tests/tests.py``` and they are configured to firefox, so you need
to have it installed in your machine
```sh
../virtualenv/bin/python manage.py test webfront
```

The functional test are in `[project]/functional_tests` and are configured to Google Chrome (or Chromium), so you need to have it installed in your machine.

To run functional tests use ```../virtualenv/bin/python manage.py test functional_tests```
To run functional tests use

* As a reference [HERE](https://docs.google.com/presentation/d/13_a6IbTq8KPGRH5AhsauEDJt4jEXNsT7DFdg1PNn4_I/edit?usp=sharing) is a graphic describing the fixtures.
```sh
export BROWSER_TEST="chrome"
# Only required if ChromeDriver is not in your PATH
# or if its binary is not `chromedriver` (e.g. `chromium.chromedriver`)
export BROWSER_TEST_PATH="/path/to/chromedriver"
../virtualenv/bin/python manage.py test functional_tests
```

As a reference [HERE](https://docs.google.com/presentation/d/13_a6IbTq8KPGRH5AhsauEDJt4jEXNsT7DFdg1PNn4_I/edit?usp=sharing) is a graphic describing the fixtures.

All the test can be run at the same time:

```../virtualenv/bin/python manage.py test```
```sh
../virtualenv/bin/python manage.py test
```

## Setting up real data (MySQL - elasticsearch)

Expand Down
9 changes: 5 additions & 4 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
selenium==3.141.0
django-debug-toolbar==3.2.2
# remember to check the version is compatible with python 3.6
selenium~=3.141
django-debug-toolbar~=3.2
ipdb==0.13.9
coveralls==3.2.0
tqdm==4.62.3
coveralls==3.3.1
tqdm==4.64.0
12 changes: 10 additions & 2 deletions functional_tests/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test import override_settings
from selenium import webdriver
from selenium.webdriver.common.by import By
import sys
import time
import os
Expand Down Expand Up @@ -47,7 +48,14 @@ def setUp(self):
if os.environ["BROWSER_TEST"] == "chrome":
chrome_options = Options()
chrome_options.add_argument("--headless")
self.browser = webdriver.Chrome(chrome_options=chrome_options)

if "BROWSER_TEST_PATH" in os.environ:
self.browser = webdriver.Chrome(
executable_path=os.environ["BROWSER_TEST_PATH"],
chrome_options=chrome_options)
else:
self.browser = webdriver.Chrome(
chrome_options=chrome_options)
else:
raise KeyError
except KeyError:
Expand All @@ -63,7 +71,7 @@ def click_link_and_wait(self, link):
def link_has_gone_stale():
try:
# poll the link with an arbitrary call
link.find_elements_by_id("doesnt-matter")
link.find_elements(By.ID, "doesnt-matter")
return False
except StaleElementReferenceException:
return True
Expand Down
25 changes: 13 additions & 12 deletions functional_tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from functional_tests.base import FunctionalTest
from selenium.webdriver.common.by import By
import json
import re


class RESTRequestsTest(FunctionalTest):
def test_request_entry_endpoint(self):
self.browser.get(self.server_url + "/api/entry/?format=json")
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text
jsonp = json.loads(content)

self.assertEqual(len(jsonp["entries"]), 5, "the output has exactly 5 keys")
Expand All @@ -20,7 +21,7 @@ def test_request_entry_endpoint(self):
)

self.browser.get(self.server_url + "/api/entry/interpro?format=json")
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)

Expand All @@ -35,7 +36,7 @@ def test_request_entry_endpoint(self):
self.browser.get(
self.server_url + "/api/entry/interpro/" + acc + "?format=json"
)
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)
self.assertEqual(
Expand All @@ -56,7 +57,7 @@ def test_request_entry_endpoint(self):

def test_request_protein_endpoint(self):
self.browser.get(self.server_url + "/api/protein/?format=json")
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)

Expand All @@ -70,7 +71,7 @@ def test_request_protein_endpoint(self):
)

self.browser.get(self.server_url + "/api/protein/uniprot?format=json")
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)

Expand All @@ -84,7 +85,7 @@ def test_request_protein_endpoint(self):
self.browser.get(
self.server_url + "/api/protein/uniprot/" + acc + "?format=json"
)
content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)
self.assertEqual(
Expand All @@ -104,7 +105,7 @@ def test_request_protein_endpoint(self):
+ jsonp["metadata"]["id"]
+ "?format=json"
)
content2 = self.browser.find_element_by_tag_name("body").text
content2 = self.browser.find_element(By.TAG_NAME, "body").text

jsonp2 = json.loads(content2)
self.assertEqual(
Expand All @@ -118,21 +119,21 @@ def test_request_to_api_frontend(self):
url = "/api/entry/"
self.browser.get(self.server_url + url)

req_info = self.browser.find_element_by_css_selector(".request-info").text
req_info = self.browser.find_element(By.CSS_SELECTOR, ".request-info").text

self.assertIn("GET", req_info)
self.assertIn(url, req_info)

response = self.browser.find_element_by_css_selector(".response-info").text
response = self.browser.find_element(By.CSS_SELECTOR, ".response-info").text
match = re.search("[\{\[]", response)
json_frontend = json.loads(response[match.start() :])

self.browser.find_element_by_css_selector(".format-selection button").click()
self.browser.find_element(By.CSS_SELECTOR, ".format-selection button").click()
self.click_link_and_wait(
self.browser.find_element_by_css_selector(".js-tooltip.format-option")
self.browser.find_element(By.CSS_SELECTOR, ".js-tooltip.format-option")
)

content = self.browser.find_element_by_tag_name("body").text
content = self.browser.find_element(By.TAG_NAME, "body").text

jsonp = json.loads(content)

Expand Down
15 changes: 7 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Django==3.2.12
djangorestframework==3.12.4
# remember to check the version is compatible with python 3.6
Django==3.2.15
djangorestframework==3.13.1
PyYAML==6.0
jsonfield2==4.0.0.post0
pymysql==1.0.2
django-cors-headers==3.10.0
django-cors-headers~=3.10
gunicorn==20.1.0
eventlet==0.32.0
django-db-connection-pool==1.0.7
django-redis==5.0.0
redis==3.5.3
requests==2.26.0
django-redis==5.2.0
redis==4.3.4
requests~=2.27
6 changes: 5 additions & 1 deletion webfront/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ class EmptyQuerysetError(Exception):
def __init__(self, message):
self.message = message


class ExpectedUniqueError(Exception):
def __init__(self, message):
self.message = message


class HmmerWebError(Exception):
def __init__(self, message):
self.message = message


class BadURLParameterError(Exception):
def __init__(self, message):
self.message = message


class InvalidOperationRequest(Exception):
def __init__(self, message):
self.message = message
self.message = message
10 changes: 4 additions & 6 deletions webfront/migrations/0010_wiki_field_type_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@

class Migration(migrations.Migration):

dependencies = [
('webfront', '0009_entry_annotation_changes'),
]
dependencies = [("webfront", "0009_entry_annotation_changes")]

operations = [
migrations.AlterField(
model_name='entry',
name='wikipedia',
model_name="entry",
name="wikipedia",
field=jsonfield.fields.JSONField(null=True),
),
)
]
14 changes: 5 additions & 9 deletions webfront/migrations/0016_structural_model_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@

class Migration(migrations.Migration):

dependencies = [
('webfront', '0015_structural_model_lddt'),
]
dependencies = [("webfront", "0015_structural_model_lddt")]

operations = [
migrations.AddField(
model_name='structuralmodel',
name='algorithm',
field=models.CharField(default='trRosetta', max_length=20),
model_name="structuralmodel",
name="algorithm",
field=models.CharField(default="trRosetta", max_length=20),
preserve_default=False,
),
migrations.AlterField(
model_name='structuralmodel',
name='lddt',
field=models.BinaryField(),
model_name="structuralmodel", name="lddt", field=models.BinaryField()
),
]
10 changes: 3 additions & 7 deletions webfront/migrations/0017_structural_model_plddt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@

class Migration(migrations.Migration):

dependencies = [
('webfront', '0016_structural_model_algorithm'),
]
dependencies = [("webfront", "0016_structural_model_algorithm")]

operations = [
migrations.RenameField(
model_name='structuralmodel',
old_name='lddt',
new_name='plddt',
),
model_name="structuralmodel", old_name="lddt", new_name="plddt"
)
]
10 changes: 3 additions & 7 deletions webfront/migrations/0018_taxa_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@

class Migration(migrations.Migration):

dependencies = [
('webfront', '0017_structural_model_plddt'),
]
dependencies = [("webfront", "0017_structural_model_plddt")]

operations = [
migrations.AddField(
model_name='entry',
name='taxa',
field=jsonfield.fields.JSONField(null=True),
),
model_name="entry", name="taxa", field=jsonfield.fields.JSONField(null=True)
)
]
28 changes: 15 additions & 13 deletions webfront/migrations/0019_entrytaxa_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@

class Migration(migrations.Migration):

dependencies = [
('webfront', '0018_taxa_modifier'),
]
dependencies = [("webfront", "0018_taxa_modifier")]

operations = [
migrations.CreateModel(
name='EntryTaxa',
name="EntryTaxa",
fields=[
('accession', models.OneToOneField(db_column='accession', on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='webfront.entry')),
('tree', jsonfield.fields.JSONField(null=True)),
(
"accession",
models.OneToOneField(
db_column="accession",
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
serialize=False,
to="webfront.entry",
),
),
("tree", jsonfield.fields.JSONField(null=True)),
],
options={
'db_table': 'webfront_entrytaxa',
},
),
migrations.RemoveField(
model_name='entry',
name='taxa',
options={"db_table": "webfront_entrytaxa"},
),
migrations.RemoveField(model_name="entry", name="taxa"),
]
16 changes: 16 additions & 0 deletions webfront/migrations/0020_alter_entryannotation_num_sequences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.12 on 2022-08-31 15:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [("webfront", "0019_entrytaxa_table")]

operations = [
migrations.AlterField(
model_name="entryannotation",
name="num_sequences",
field=models.IntegerField(null=True),
)
]
2 changes: 1 addition & 1 deletion webfront/models/interpro_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EntryAnnotation(models.Model):
type = models.CharField(max_length=32)
value = models.BinaryField()
mime_type = models.CharField(max_length=32)
num_sequences = models.FloatField(null=True)
num_sequences = models.IntegerField(null=True)


class Protein(models.Model):
Expand Down
Loading

0 comments on commit 371c14f

Please sign in to comment.