Skip to content

Commit

Permalink
added test codes
Browse files Browse the repository at this point in the history
  • Loading branch information
avikdatta committed Dec 24, 2022
1 parent e04182b commit 08f9906
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ dump.rdb
celery_flower.sh
.env
backup.sql
nginx.conf
./static/*
app/static/bclconvert_report_v0.02.html
app/static/MultiQC_lane1.html
app/static/MultiQC_lane1.html:Zone.Identifier
13 changes: 13 additions & 0 deletions app/raw_analysis_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging, tempfile, os
from io import BytesIO
from .models import RawAnalysis, RawMetadataModel
from flask_appbuilder import ModelView
Expand All @@ -6,6 +7,17 @@
from flask_appbuilder.actions import action
from flask_appbuilder.models.sqla.interface import SQLAInterface
from . import db
from . import celery
from .raw_analysis.raw_analysis_util import validate_analysis_json

@celery.task(bind=True)
def async_validate_analysis_yaml(self, id_list):
try:
pass
except Exception as e:
logging.error(
"Failed to run celery job, error: {0}".\
format(e))

class RawAnalysisView(ModelView):
datamodel = SQLAInterface(RawAnalysis)
Expand All @@ -16,6 +28,7 @@ class RawAnalysisView(ModelView):
base_filters = [
["status", FilterInFunction, lambda: ["UNKNOWN", "FAILED"]]]
base_order = ("raw_analysis_id", "desc")

@action("validate_and_submit_analysis", "Validate and upload analysis", confirmation="Validate analysis design?", icon="fa-rocket")
def validate_and_submit_analysis(self, item):
analysis_list = list()
Expand Down
6 changes: 6 additions & 0 deletions app/templates/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "appbuilder/base.html" %}

{% block content %}
<h3 align="left"><a href="/sampleindexview/list/">Go Back to run list</a></h3>
<iframe src="{{url}}" frameborder='0' noresize='noresize' style='position: absolute; background: transparent; width: 100%; height:100%;' title="description" frameborder="0"></iframe>
{% endblock %}
26 changes: 23 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ services:
image: mysql:5.7
env_file: env
restart: always
ports:
- "3306:3306"
volumes:
- /home/vmuser/mysqlappdb:/var/lib/mysql:rw
container_name: portal_db
Expand All @@ -22,7 +24,7 @@ services:
image: igfportal:v0.0.1
env_file: env
ports:
- "8080:8080"
- 8080:8080
restart: always
links:
- portal_db
Expand All @@ -33,8 +35,26 @@ services:
volumes:
- /home/vmuser/github/IGFPortal:/github/IGFPortal:ro
- /home/vmuser/github/ssl:/SSL:ro
- ./static:/data/static:rw
container_name: webserver
command: ["flask run -h 0.0.0.0 -p 8080 --cert=/SSL/cert.pem --key=/SSL/key.pem --reload --debugger --without-threads"]
command: ["flask run -h 0.0.0.0 -p 8080 --reload --debugger --without-threads"]
networks:
- portal_network
nginx:
image: nginx:1.23.3
ports:
- "80:80"
- "443:443"
links:
- webserver
depends_on:
- webserver
volumes:
- /home/vmuser/github/ssl:/SSL:ro
- /home/vmuser/github/IGFPortal/nginx.conf:/etc/nginx/nginx.conf:ro
- /tmp/nginx:/var/nginx/:rw
- ./static:/data/static:rw
container_name: nginx
networks:
- portal_network
celery_worker1:
Expand Down Expand Up @@ -81,4 +101,4 @@ services:
restart: always
container_name: adminer
networks:
- portal_network
- portal_network
63 changes: 63 additions & 0 deletions nginx_template.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
worker_processes 2;
user nobody nogroup;

error_log /var/nginx/error.log warn;
pid /var/nginx/run/nginx.pid;

events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
# 'use epoll;' to enable for Linux 2.6+
# 'use kqueue;' to enable for FreeBSD, OSX
}

http {
include mime.types;
# fallback in case we can't determine a type
default_type application/octet-stream;
access_log /var/nginx/access.log combined;
sendfile on;

ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

upstream app_server {
server webserver:8080 fail_timeout=0;
}

server {
# if no Host match, close the connection to prevent host spoofing
listen 80 default_server;
return 444;
}

server {
# Redirect http to https
listen 80 default_server;
server_name localhost;
return 301 https://localhost$request_uri;
}

server {
listen 443 ssl;
ssl_certificate /SSL/cert.pem;
ssl_certificate_key /SSL/key.pem;
keepalive_timeout 70s;
server_name localhost;
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://app_server;
}

error_page 500 502 503 504 /500.html;
}
}
36 changes: 36 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os, unittest, tempfile
from flask.testing import FlaskClient
from app import app, db, appbuilder
from flask import Flask, g, url_for


class TestCase1(unittest.TestCase):
def setUp(self):
app.app_context().push()
app.config.from_object("flask_appbuilder.tests.config_api")
db.create_all()
self.client = app.test_client(use_cookies=True)
app.appbuilder.sm.add_user(
"admin",
"admin",
"user",
"admin@fab.org",
"Admin",
"password")


def tearDown(self):
self.appbuilder = None
db.drop_all()

def test_access_server(self):
uri = "/"
rv = self.client.get(uri)
#self.assertEqual(rv.status_code, 200)
print(rv.status_code)




if __name__ == '__main__':
unittest.main()

0 comments on commit 08f9906

Please sign in to comment.