Commit 5389788c authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

flake8 and refacto

parent 94f0faad
from .gene import GeneAdmin
from .function import FunctionAdmin, KeggOrthologyAdmin
__all__ = ['GeneAdmin', 'FunctionAdmin', 'KeggOrthologyAdmin']
......@@ -26,4 +26,3 @@ class FunctionAdmin(admin.ModelAdmin):
list_display = ('function_id', 'name', 'source')
search_fields = ('function_id',)
......@@ -18,13 +18,13 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('function_id', models.CharField(db_index=True, max_length=100)),
('name', models.CharField(max_length=100)),
('source', models.CharField(choices=[('undef', 'Undefined'), ('kegg', 'KEGG'), ('eggnog', 'EggNOG')], default='undef', max_length=10)),
('source', models.CharField(choices=[('undef', 'Undefined'), ('kegg', 'KEGG'), ('eggnog', 'EggNOG')], default='undef', max_length=10)), # noqa
],
),
migrations.CreateModel(
name='KeggOrthology',
fields=[
('function_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='catalog.Function')),
('function_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='catalog.Function')), # noqa
('ec_number', models.CharField(blank=True, default='', max_length=200)),
('long_name', models.CharField(max_length=500)),
],
......
from .function import Function, KeggOrthology
from .gene import Gene
__all__ = ['Function', 'KeggOrthology', 'Gene']
......@@ -10,4 +10,3 @@ class Gene(models.Model):
def __str__(self):
return self.gene_id
......@@ -14,4 +14,3 @@ class GeneSerializer(serializers.ModelSerializer):
class Meta:
model = Gene
fields = ('gene_id', 'gene_length', 'functions')
from django.test import TestCase
# Create your tests here.
......@@ -11,6 +11,7 @@ from .serializers import GeneSerializer
def index(request):
return HttpResponse(f"Welcome to the catalog page.")
@api_view(['GET'])
def gene_list(request):
"""
......@@ -37,7 +38,7 @@ def gene_list(request):
return Response({'data': serializer.data, 'count': paginator.count, 'numpages': paginator.num_pages,
'nextlink': '/api/genes/?page=' + str(nextPage),
'prevlink': '/api/genes/?page=' + str(previousPage)})
@api_view(['GET'])
def gene_detail(request, gene_id):
......
from django.contrib.auth.models import User
from django.test import TestCase
class TestDatabase(TestCase):
def test_create_user(self):
user = User.objects.create_user(
username='user',
email='user@foo.com',
password='pass'
)
user.save()
user_count = User.objects.all().count()
self.assertEqual(user_count, 1)
......@@ -16,7 +16,6 @@ Including another URLconf
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
urlpatterns = [
path('admin/', admin.site.urls),
......
......@@ -49,3 +49,4 @@ traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2
flake8
......@@ -12,7 +12,7 @@ from django.core.exceptions import ValidationError
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "metagenedb.settings")
django.setup()
from metagenedb.apps.catalog.models import Gene, Function
from metagenedb.apps.catalog.models import Gene, Function # noqa
logging.basicConfig(level=logging.INFO)
_LOGGER = logging.getLogger(__name__)
......
......@@ -12,7 +12,7 @@ from django.core.exceptions import ValidationError
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "metagenedb.settings")
django.setup()
from metagenedb.apps.catalog.models import KeggOrthology
from metagenedb.apps.catalog.models import KeggOrthology # noqa
logging.basicConfig(level=logging.INFO)
_LOGGER = logging.getLogger(__name__)
......@@ -62,7 +62,7 @@ def create_kegg_ko(kegg_ko):
def run():
args = parse_arguments()
args = parse_arguments() # noqa
all_ko = requests.get("http://rest.kegg.jp/list/ko")
all_ko.raise_for_status()
inserted_kegg = 0
......@@ -84,6 +84,5 @@ def run():
# Create unknown entry
if __name__ == "__main__":
run()
......@@ -11,5 +11,4 @@ setup(name="metagenedb",
'djangorestframework'
],
packages=find_packages(),
scripts=['scripts/manage.py'],
)
scripts=['scripts/manage.py'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment