예제 #1
0
 def test_directions(self):
     tester = app.test_client(self)
     response = tester.get(
         '/api/v1/directions?filename=TEST-DO-NOT-UPDATE-DELETE',
         content_type='application/json')
     self.assertEqual(response.status_code, 200)
     resp = json.loads(response.data)
     self.assertEqual(resp['data'], testResponseData)
예제 #2
0
 def test_directions_not_found(self):
     tester = app.test_client(self)
     response = tester.get('/api/v1/path', content_type='application/json')
     self.assertEqual(response.status_code, 404)
     resp = json.loads(response.data)
     self.assertEqual(resp['message'],
                      'The route you requested for was not found')
     self.assertEqual(resp['status'], 404)
예제 #3
0
 def test_directions_filename_required(self):
     tester = app.test_client(self)
     response = tester.get('/api/v1/directions',
                           content_type='application/json')
     self.assertEqual(response.status_code, 400)
     resp = json.loads(response.data)
     self.assertEqual(resp['message'],
                      'filename is missing in the url query')
     self.assertEqual(resp['status'], 400)
예제 #4
0
 def test_directions_file_read_error(self):
     tester = app.test_client(self)
     response = tester.get('/api/v1/directions?filename=filename',
                           content_type='application/json')
     self.assertEqual(response.status_code, 500)
     resp = json.loads(response.data)
     self.assertEqual(
         resp['message'],
         'An error occured while retrieving file or file doesn\'t exist')
     self.assertEqual(resp['status'], 500)
예제 #5
0
def before_all(context):
    context.app = app.test_client()
예제 #6
0
    def setUp(self):
        os.environ['ES_URI'] = 'http://localhost:9200/'
        from src.server import app

        self.es_search_response = {
            "took": 4,
            "timed_out": False,
            "_shards": {
                "total": 5,
                "successful": 5,
                "failed": 0
            },
            "hits": {
                "total":
                120735,
                "max_score":
                1.0,
                "hits": [{
                    "_index": "searchable_items_prototype",
                    "_type": "searchable_item",
                    "_id": "yeast_S00001",
                    "_score": 1.0,
                    "_source": {
                        "name": "ACTin 1",
                        "symbol": "ACT1",
                        "href": "yeastgenome.org/locus/act1/overview",
                        "category": "gene"
                    }
                }]
            }
        }

        self.es_aggregation_response = {
            "took": 12,
            "timed_out": False,
            "_shards": {
                "total": 5,
                "successful": 5,
                "failed": 0
            },
            "hits": {
                "total": 120735,
                "max_score": 0.0,
                "hits": []
            },
            "aggregations": {
                "categories": {
                    "doc_count_error_upper_bound":
                    0,
                    "sum_other_doc_count":
                    312,
                    "buckets": [{
                        "key": "gene",
                        "doc_count": 6691
                    }, {
                        "key": "go",
                        "doc_count": 387
                    }, {
                        "key": "diseases",
                        "doc_count": 352
                    }]
                }
            }
        }
        self.index = 'searchable_items_blue'
        self.search_fields = [
            'id', 'name', 'gene_symbol', 'gene_synonyms', 'description',
            'external_ids', 'species', 'gene_biological_process',
            'gene_molecular_function', 'gene_cellular_component', 'go_type',
            'go_genes', 'go_synonyms', 'disease_genes', 'disease_synonyms',
            'homologs.symbol', 'homologs.panther_family'
        ]
        self.json_response_fields = [
            'name', 'gene_symbol', 'gene_synonyms', 'gene_type',
            'gene_chromosomes', 'gene_chromosome_starts',
            'gene_chromosome_ends', 'description', 'external_ids', 'species',
            'gene_biological_process', 'gene_molecular_function',
            'gene_cellular_component', 'go_type', 'go_genes', 'go_synonyms',
            'disease_genes', 'disease_synonyms', 'homologs', 'category', 'href'
        ]
        self.category_filters = {
            "gene": [
                'gene_type', 'gene_biological_process',
                'gene_molecular_function', 'gene_cellular_component', 'species'
            ],
            "go": ['go_type', 'go_species', 'go_genes'],
            "disease": ['disease_species', 'disease_genes']
        }

        self.app = app.test_client()
        self.app.testing = True
예제 #7
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True
예제 #8
0
import json
import unittest

from src.server import app

TEST_DB = 'test.db'


class FlaskTestClient(object):
    def __init__(self, app):
        self.app = app

    def __call__(self, environ, start_response):
        environ['REMOTE_ADDR'] = environ.get('REMOTE_ADDR', '127.0.0.1')
        environ['HTTP_USER_AGENT'] = environ.get('HTTP_USER_AGENT', 'Chrome')
        return self.app(environ, start_response)


app.wsgi_app = FlaskTestClient(app.wsgi_app)
client = app.test_client()
client.post('/newJob', data=json.dumps({'url': "google.com"}))

if __name__ == "__main__":
    unittest.main()
예제 #9
0
def client():
    client = app.test_client()

    yield client
예제 #10
0
def test_client():
    with app.test_client() as client:
        yield client
예제 #11
0
def test_client():
    app.testing = True
    return app.test_client()
예제 #12
0
def test_client():
    from src.server import app
    app.testing = True
    yield app.test_client()
예제 #13
0
 def setUp(self):
     app.config["TESTING"] = True
     app.config["WTF_CSRF_ENABLED"] = False
     self.app = app.test_client()
예제 #14
0
 def setUp(self):
     self.test_client = app.test_client()
예제 #15
0
    def setUp(self):
        os.environ['ES_URI'] = 'http://localhost:9200/'
        from src.server import app

        self.es_search_response = {
            "took": 4,
            "timed_out": False,
            "_shards": {
                "total": 5,
                "successful": 5,
                "failed": 0
            },
            "hits": {
                "total":
                120735,
                "max_score":
                1.0,
                "hits": [{
                    "_index": "searchable_items_prototype",
                    "_type": "searchable_item",
                    "_id": "yeast_S00001",
                    "_score": 1.0,
                    "_source": {
                        "name": "ACTin 1",
                        "symbol": "ACT1",
                        "href": "yeastgenome.org/locus/act1/overview",
                        "category": "gene"
                    }
                }]
            }
        }

        self.es_aggregation_response = {
            "took": 12,
            "timed_out": False,
            "_shards": {
                "total": 5,
                "successful": 5,
                "failed": 0
            },
            "hits": {
                "total": 120735,
                "max_score": 0.0,
                "hits": []
            },
            "aggregations": {
                "categories": {
                    "doc_count_error_upper_bound":
                    0,
                    "sum_other_doc_count":
                    312,
                    "buckets": [{
                        "key": "gene",
                        "doc_count": 6691
                    }, {
                        "key": "go",
                        "doc_count": 387
                    }, {
                        "key": "diseases",
                        "doc_count": 352
                    }]
                }
            }
        }
        self.index = 'searchable_items_prototype'
        self.search_fields = [
            'name', 'symbol', 'synonym', 'go_ids', 'go_names'
        ]
        self.json_response_fields = [
            'name', 'symbol', 'synonym', 'go_ids', 'go_names', 'href', 'type',
            'organism'
        ]
        self.category_filters = {
            "gene": ['go_ids', 'go_names'],
            "go": ['gene']
        }

        self.app = app.test_client()
        self.app.testing = True