Exemplo n.º 1
0
def test_post_add_file_daily():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().post(
        '/addfile', data={"file": (BytesIO(b'content'), "06-05-2020.csv")})
    # check for redirect
    assert response.status_code == 302
Exemplo n.º 2
0
 def test_output_uploaded_data(self):
     """Integration Test for output Uploaded Data"""
     res = mock_file_upload(DR_US)
     assert res.status_code == 201
     response = app.test_client().get('/deaths?output=json')
     expected = [{
         "datetime": "01-02-21",
         "country_region": "US",
         "province_state": "Alabama",
         "combined_key": "",
         "admin": "",
         "deaths": 4872
     }, {
         "datetime": "01-02-21",
         "country_region": "US",
         "province_state": "Alaska",
         "combined_key": "",
         "admin": "",
         "deaths": 215
     }, {
         "datetime": "01-02-21",
         "country_region": "US",
         "province_state": "American Samoa",
         "combined_key": "",
         "admin": "",
         "deaths": 0
     }]
     self.assertEqual(response.json, expected)
     path = os.path.join("COVIDMonitor/data", ntpath.basename(DR_US))
     os.unlink(path)
     assert response.status_code == 200
Exemplo n.º 3
0
    def setUp(self) -> None:
        self.client = app.test_client()
        f = FileStorage(stream=open(TS_GLOBAL, "rb"),
                        filename=ntpath.basename(TS_GLOBAL)),

        self.client.post('/upload',
                         content_type='multipart/form-data',
                         data={'file': f})
Exemplo n.º 4
0
def test_post_add_file_time_series():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().post(
        '/addfile',
        data={
            "file":
            (BytesIO(b'content'), "time_series_covid19_confirmed_global.csv")
        })
    # check for redirect
    assert response.status_code == 302
Exemplo n.º 5
0
def mock_file_upload(path):
    """
    Mock the upload process and
    Return the response
    """
    client = app.test_client()
    f = FileStorage(stream=open(path, "rb"), filename=ntpath.basename(path)),

    response = client.post('/upload',
                           content_type='multipart/form-data',
                           data={'file': f})

    return response
def test_monitor():
	response = app.test_client().get('/monitor')

	assert response.status_code == 200
	assert response.data == b'Welcome to the Covid Monitor!'
Exemplo n.º 7
0
 def setUp(self) -> None:
     self.outputAgent = OutputFactory()
     self.client = app.test_client()
     self.client.get('/')
     self.interface = OutputFactoryInterface()
Exemplo n.º 8
0
 def setUp(self) -> None:
     """Set up the necessary testing client"""
     self.client = app.test_client()
Exemplo n.º 9
0
def test_get_return_time_series_data():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().get('/return-time-series-data')

    assert response.status_code == 403
Exemplo n.º 10
0
def test_filter_time_series():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().get('/filter-time-series')

    assert response.status_code == 200
Exemplo n.º 11
0
def test_filter_daily():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().get('/filter-daily')

    assert response.status_code == 200
Exemplo n.º 12
0
def test_get_add_file():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().get('/addfile')

    assert response.status_code == 403
Exemplo n.º 13
0
def test_post_no_file_sent():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().post('/addfile')
    # check for redirect
    assert response.status_code == 302
Exemplo n.º 14
0
def test_monitor():
    app = Flask(__name__)
    configure_routes(app)
    response = app.test_client().get('/')

    assert response.status_code == 200