bptk-py
Advanced tools
| Metadata-Version: 2.4 | ||
| Name: bptk-py | ||
| Version: 2.0.0 | ||
| Version: 2.1.0 | ||
| Summary: A python simulation engine for System Dynamics & Agent based models | ||
@@ -79,2 +79,9 @@ Author-email: transentis <support@transentis.com> | ||
| ### 2.0.1 | ||
| * added unittests | ||
| * fixed typos for server output | ||
| * enabled operations: not named vector and int/float | ||
| * fixed issue with configurable file-path for bptk-object | ||
| ### 2.0.0 | ||
@@ -81,0 +88,0 @@ |
@@ -590,4 +590,6 @@ # /`- | ||
| def is_named(self): | ||
| return (self.element_1.named_arrayed or self.element_2.named_arrayed) | ||
| e1_named = getattr(self.element_1, 'named_arrayed', False) | ||
| e2_named = getattr(self.element_2, 'named_arrayed', False) | ||
| return (e1_named or e2_named) | ||
| def clone_with_index(self, index): | ||
@@ -669,5 +671,6 @@ element_1 = self.element_1 if isinstance( | ||
| def is_named(self): | ||
| return (self.element_1.named_arrayed or self.element_2.named_arrayed) | ||
| e1_named = getattr(self.element_1, 'named_arrayed', False) | ||
| e2_named = getattr(self.element_2, 'named_arrayed', False) | ||
| return (e1_named or e2_named) | ||
| class DivisionOperator(BinaryOperator): | ||
@@ -740,4 +743,6 @@ def term(self, time="t"): | ||
| def is_named(self): | ||
| return (self.element_1.named_arrayed or self.element_2.named_arrayed) | ||
| e1_named = getattr(self.element_1, 'named_arrayed', False) | ||
| e2_named = getattr(self.element_2, 'named_arrayed', False) | ||
| return (e1_named or e2_named) | ||
| class NumericalMultiplicationOperator(BinaryOperator): | ||
@@ -853,3 +858,5 @@ def term(self, time="t"): | ||
| def is_named(self): | ||
| return (self.element_1.named_arrayed or self.element_2.named_arrayed) | ||
| e1_named = getattr(self.element_1, 'named_arrayed', False) | ||
| e2_named = getattr(self.element_2, 'named_arrayed', False) | ||
| return (e1_named or e2_named) | ||
@@ -856,0 +863,0 @@ def resolve_dimensions(self): |
@@ -387,3 +387,3 @@ # /`- | ||
| except KeyError: | ||
| resp = make_response('{"error": "expecting scenario_managers to be set"}', 500) | ||
| resp = make_response('{"error": "expecting scenarios to be set"}', 500) | ||
| resp.headers['Content-Type']='application/json' | ||
@@ -788,3 +788,3 @@ resp.headers['Access-Control-Allow-Origin']='*' | ||
| if(instance.is_locked()): | ||
| resp = make_response('{"error": "instace is locked"}', 500) | ||
| resp = make_response('{"error": "instance is locked"}', 500) | ||
| resp.headers['Content-Type'] = 'application/json' | ||
@@ -838,9 +838,9 @@ resp.headers['Access-Control-Allow-Origin'] = '*' | ||
| if not request.is_json: | ||
| resp = make_response('{"error": "expecting a number of steps to be provided in the body as a json {numberSteps: int}"}', 500) | ||
| resp = make_response('{"error": "please pass the request with content-type application/json"}',500) | ||
| resp.headers['Content-Type'] = 'application/json' | ||
| resp.headers['Access-Control-Allow-Origin'] = '*' | ||
| resp.headers['Access-Control-Allow-Origin']='*' | ||
| return resp | ||
| if(instance.is_locked()): | ||
| resp = make_response('{"error": "instace is locked"}', 500) | ||
| resp = make_response('{"error": "instance is locked"}', 500) | ||
| resp.headers['Content-Type'] = 'application/json' | ||
@@ -910,3 +910,3 @@ resp.headers['Access-Control-Allow-Origin'] = '*' | ||
| if(instance.is_locked()): | ||
| resp = make_response('{"error": "instace is locked"}', 500) | ||
| resp = make_response('{"error": "instance is locked"}', 500) | ||
| resp.headers['Content-Type'] = 'application/json' | ||
@@ -913,0 +913,0 @@ resp.headers['Access-Control-Allow-Origin'] = '*' |
@@ -28,3 +28,3 @@ # /`- | ||
| def plot(self, df, return_df, visualize_from_period, visualize_to_period, stacked, kind, title, alpha, x_label, | ||
| y_label, start_date="1/1/2018", freq="D", series_names={}): | ||
| y_label, start_date="1/1/2018", freq="D", series_names={},format="plot"): | ||
| """ | ||
@@ -45,3 +45,3 @@ Plot method. Creates plots from dataframes | ||
| :param series_names: series renaming patterns | ||
| :return: DataFrame or Matplotlib Subplot, depends on return_df flag | ||
| :return: depends on format flag: either just a plot, which formally returns nothing, or Matplotlib axes, or a dataframe | ||
| """ | ||
@@ -76,3 +76,3 @@ | ||
| ## If user did not set return_df=True, plot the simulation results (default behavior) | ||
| if not return_df: | ||
| if not (return_df or format=="df"): | ||
@@ -115,6 +115,10 @@ ### Get the plot object | ||
| self.update_plot_formats(ax) | ||
| return | ||
| if format=="axes": | ||
| return ax | ||
| else: | ||
| return | ||
| ### If user wanted a dataframe instead, here it is! | ||
| elif return_df: | ||
| elif return_df or format=="df": | ||
| if visualize_to_period == 0: | ||
@@ -163,2 +167,2 @@ return df.iloc[visualize_from_period:] | ||
| except: | ||
| pass | ||
| pass |
+8
-1
| Metadata-Version: 2.4 | ||
| Name: bptk-py | ||
| Version: 2.0.0 | ||
| Version: 2.1.0 | ||
| Summary: A python simulation engine for System Dynamics & Agent based models | ||
@@ -79,2 +79,9 @@ Author-email: transentis <support@transentis.com> | ||
| ### 2.0.1 | ||
| * added unittests | ||
| * fixed typos for server output | ||
| * enabled operations: not named vector and int/float | ||
| * fixed issue with configurable file-path for bptk-object | ||
| ### 2.0.0 | ||
@@ -81,0 +88,0 @@ |
+7
-0
@@ -44,2 +44,9 @@ # Business Prototyping Toolkit for Python | ||
| ### 2.0.1 | ||
| * added unittests | ||
| * fixed typos for server output | ||
| * enabled operations: not named vector and int/float | ||
| * fixed issue with configurable file-path for bptk-object | ||
| ### 2.0.0 | ||
@@ -46,0 +53,0 @@ |
+1
-1
@@ -15,3 +15,3 @@ from setuptools import setup | ||
| def get_version(): | ||
| return '2.0.0' | ||
| return '2.1.0' | ||
@@ -18,0 +18,0 @@ setup(version=get_version(), |
+340
-34
@@ -34,3 +34,2 @@ from BPTK_Py.server import BptkServer | ||
| bptk = BPTK_Py.bptk() | ||
@@ -42,3 +41,2 @@ | ||
| bptk.register_scenarios( | ||
| scenario_manager="firstManager", | ||
@@ -53,10 +51,6 @@ scenarios= | ||
| } | ||
| } | ||
| ) | ||
| bptk.register_scenarios( | ||
| scenario_manager="secondManager", | ||
@@ -81,6 +75,3 @@ scenarios= | ||
| } | ||
| } | ||
| ) | ||
@@ -95,3 +86,2 @@ | ||
| @pytest.fixture | ||
@@ -101,2 +91,25 @@ def client(app): | ||
| def empty_bptk_factory(): | ||
| model = Model(starttime=1.0,stoptime=50.0, dt=1.0, name="Test Model") | ||
| stock = model.stock("stock") | ||
| flow = model.flow("flow") | ||
| constant = model.constant("constant") | ||
| stock.initial_value=0.0 | ||
| stock.equation=flow | ||
| flow.equation=constant | ||
| constant.equation=1.0 | ||
| bptk = BPTK_Py.bptk() | ||
| return bptk | ||
| @pytest.fixture | ||
| def empty_app(): | ||
| flask_app = BptkServer(__name__, empty_bptk_factory,None,token) | ||
| yield flask_app | ||
| @pytest.fixture | ||
| def empty_client(empty_app): | ||
| return empty_app.test_client() | ||
| def test_home_resource(app, client): | ||
@@ -118,23 +131,109 @@ response = client.get('/') | ||
| "equations":["stock","flow","constant"], | ||
| "agents" : ["agent"], | ||
| "agent_states": ["agent_state"], | ||
| "agent_properties" : ["agent_property"], | ||
| "agent_property_types" : ["agent_property_type"], | ||
| "settings":{ | ||
| "firstManager":{ | ||
| "1":{ | ||
| "constants": { | ||
| "constant":7.0 | ||
| }, | ||
| "points": { | ||
| "point" : [ | ||
| [0, 0.1], | ||
| [1, 0.9] | ||
| ] | ||
| }, | ||
| "runspecs": { | ||
| "starttime": 1.0, | ||
| "stoptime": 15.0, | ||
| "dt": 1.0 | ||
| } | ||
| #properties and agents not defined for SimulationScenario -> Bug? | ||
| } | ||
| } | ||
| } | ||
| } | ||
| "firstManager": | ||
| { | ||
| "1": | ||
| { | ||
| "constants": | ||
| { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| response = client.post('/run', data=json.dumps(query), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200 # checking the status code | ||
| #error if data is not json | ||
| response_with_not_json = client.post('/run', data=query, headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_not_json.status_code == 500 # checking the status code | ||
| assert b'please pass the request with content-type application/json' in response_with_not_json.data | ||
| #errors for no result (missing content included) | ||
| query_with_missing_settings={ | ||
| "scenario_managers":["firstManager"], | ||
| "scenarios":["1"], | ||
| "agents":["agent"], | ||
| } | ||
| response = client.post('/run', data=json.dumps(query), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| response_with_missing_settings = client.post('/run', data=json.dumps(query_with_missing_settings), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200 # checking the status code | ||
| assert response_with_missing_settings.status_code == 500 # checking the status code | ||
| assert b'no data was returned from simulation' in response_with_missing_settings.data | ||
| query_with_missing_manager={ | ||
| "scenarios":["1"], | ||
| "equations":["stock","flow","constant"], | ||
| "settings":{ | ||
| "firstManager":{ | ||
| "1":{ | ||
| "constants": { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| response_with_missing_manager = client.post('/run', data=json.dumps(query_with_missing_manager), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_manager.status_code == 500 # checking the status code | ||
| assert b'expecting scenario_managers to be set' in response_with_missing_manager.data | ||
| query_with_missing_scenarios={ | ||
| "scenario_managers":["firstManager"], | ||
| "equations":["stock","flow","constant"], | ||
| "settings":{ | ||
| "firstManager":{ | ||
| "1":{ | ||
| "constants": { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| response_with_missing_scenarios = client.post('/run', data=json.dumps(query_with_missing_scenarios), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_scenarios.status_code == 500 # checking the status code | ||
| assert b'expecting scenarios to be set' in response_with_missing_scenarios.data | ||
| query_with_missing_equations_and_agents={ | ||
| "scenario_managers":["firstManager"], | ||
| "scenarios":["1"], | ||
| "settings":{ | ||
| "firstManager":{ | ||
| "1":{ | ||
| "constants": { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| response_with_missing_equations_and_agents = client.post('/run', data=json.dumps(query_with_missing_equations_and_agents), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_equations_and_agents.status_code == 500 # checking the status code | ||
| assert b'expecting either equations or agents to be set' in response_with_missing_equations_and_agents.data | ||
| def test_run_steps_resource(app, client): | ||
@@ -241,3 +340,3 @@ | ||
| def test_scenarios_resource(app, client): | ||
| def test_scenarios_resource(app, client, empty_app, empty_client): | ||
| response = client.get('/scenarios',headers={"Authorization": f"Bearer {token}"}) | ||
@@ -249,17 +348,81 @@ data=json.loads(response.data) | ||
| #check for missing scenarios | ||
| reponse_with_missing_scenarios = empty_client.get('/scenarios',headers={"Authorization": f"Bearer {token}"}) | ||
| assert reponse_with_missing_scenarios.status_code == 500 | ||
| assert b'expecting the model to have scenarios' in reponse_with_missing_scenarios.data | ||
| def test_equations_resource(app, client): | ||
| query = { | ||
| query1 = { | ||
| "scenarioManager": "firstManager", | ||
| "scenario":"1" | ||
| } | ||
| response = client.post('/equations', data=json.dumps(query), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200 # Checking the status code | ||
| equations = [b"constants", b"converters", b"flows", b"points"] | ||
| for equation in equations: # checking words in request data | ||
| assert equation in response.data | ||
| query2 = { | ||
| "scenario_manager": "firstManager", | ||
| "scenario":"1" | ||
| } | ||
| response1 = client.post('/equations', data=json.dumps(query1), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response1.status_code == 200 # Checking the status code | ||
| equations1 = [b"constants", b"converters", b"flows", b"points"] | ||
| for equation in equations1: # checking words in request data | ||
| assert equation in response1.data | ||
| response2 = client.post('/equations', data=json.dumps(query2), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response2.status_code == 200 # Checking the status code | ||
| equations2 = [b"constants", b"converters", b"flows", b"points"] | ||
| for equation in equations2: # checking words in request data | ||
| assert equation in response2.data | ||
| #error if data is not json | ||
| response_with_not_json = client.post('/equations', data=query1, headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_not_json.status_code == 500 # checking the status code | ||
| assert b'please pass the request with content-type application/json' in response_with_not_json.data | ||
| #error if scenarioManager is Missing | ||
| query_with_missing_manager = { | ||
| "scenario":"1" | ||
| } | ||
| response_with_missing_manager = client.post('/equations', data=json.dumps(query_with_missing_manager), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_manager.status_code == 500 # checking the status code | ||
| assert b'expecting scenarioManager or scenario_manager to be set' in response_with_missing_manager.data | ||
| #error if scenario is Missing | ||
| query_with_missing_scenario = { | ||
| "scenarioManager": "firstManager" | ||
| } | ||
| response_with_missing_scenario = client.post('/equations', data=json.dumps(query_with_missing_scenario), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_scenario.status_code == 500 # checking the status code | ||
| assert b'expecting scenario to be set' in response_with_missing_scenario.data | ||
| def test_agents_resource(app, client): | ||
| response = client.post('/agents', content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 400 # System dynamics systems shouldn't have agents | ||
| #error if data is not json | ||
| empty_query = {} | ||
| response_with_not_json = client.post('/agents', data=empty_query, headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_not_json.status_code == 500 # checking the status code | ||
| assert b'please pass the request with content-type application/json' in response_with_not_json.data | ||
| #error if scenarioManager is Missing | ||
| query_with_missing_manager = { | ||
| "scenario":"1" | ||
| } | ||
| response_with_missing_manager = client.post('/agents', data=json.dumps(query_with_missing_manager), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_manager.status_code == 500 # checking the status code | ||
| assert b'expecting scenarioManager to be set' in response_with_missing_manager.data | ||
| #error if scenario is Missing | ||
| query_with_missing_scenario = { | ||
| "scenarioManager": "firstManager" | ||
| } | ||
| response_with_missing_scenario = client.post('/agents', data=json.dumps(query_with_missing_scenario), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_scenario.status_code == 500 # checking the status code | ||
| assert b'expecting scenario to be set' in response_with_missing_scenario.data | ||
| #error if scenario has no agents | ||
| query = { | ||
| "scenarioManager": "firstManager", | ||
| "scenario":"1" } | ||
| response = client.post('/agents', data=json.dumps(query), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 500 # checking the status code | ||
| assert b'expecting the model to have agents' in response.data | ||
| #To do: Add tests for an actual Agent based or hybrid model | ||
| def test_metrics(app, client): | ||
@@ -443,3 +606,47 @@ response = client.get('/metrics') | ||
| id = json.loads(response.data)['instance_uuid'] | ||
| invalid_id= id + '1' | ||
| #error if scenario manager is missing | ||
| session_with_missing_sm = { | ||
| "scenarios": [ | ||
| "1" | ||
| ], | ||
| "equations": [ | ||
| "stock", | ||
| "flow", | ||
| "constant", | ||
| ] | ||
| } | ||
| response_with_no_sm = client.post('/' + id + '/begin-session', data=json.dumps(session_with_missing_sm), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_no_sm.status_code == 500 # checking the status code | ||
| assert b'expecting scenario_managers to be set' in response_with_no_sm.data | ||
| #error if scenario is missing | ||
| session_with_missing_scenario = { | ||
| "scenario_managers": [ | ||
| "firstManager" | ||
| ], | ||
| "equations": [ | ||
| "stock", | ||
| "flow", | ||
| "constant", | ||
| ] | ||
| } | ||
| response_with_no_scenario = client.post('/' + id + '/begin-session', data=json.dumps(session_with_missing_scenario), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_no_scenario.status_code == 500 # checking the status code | ||
| assert b'expecting scenarios to be set' in response_with_no_scenario.data | ||
| #error if equations and agents are missing | ||
| session_with_missing_equations_and_agents = { | ||
| "scenario_managers": [ | ||
| "firstManager" | ||
| ], | ||
| "scenarios": [ | ||
| "1" | ||
| ], | ||
| } | ||
| response_with_no_equations_and_agents = client.post('/' + id + '/begin-session', data=json.dumps(session_with_missing_equations_and_agents), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_no_equations_and_agents.status_code == 500 # checking the status code | ||
| assert b'expecting either equations or agents to be set' in response_with_no_equations_and_agents.data | ||
| session = { | ||
@@ -459,6 +666,39 @@ "scenario_managers": [ | ||
| #error if data is not json | ||
| response_with_not_json = client.post('/' + id + '/begin-session', data=session, headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_not_json.status_code == 500 # checking the status code | ||
| assert b'please pass the request with content-type application/json' in response_with_not_json.data | ||
| #error if instance id does not exist | ||
| response_with_invalid_id = client.post('/' + invalid_id + '/begin-session', data=json.dumps(session), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id.data | ||
| #valid request | ||
| response = client.post('/' + id + '/begin-session', data=json.dumps(session), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200, "begin-session response should be 200" | ||
| #run step: error if instance id does not exist | ||
| query_single_step={ | ||
| "settings": { | ||
| "firstManager": { | ||
| "1": { | ||
| "constants": { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| response_with_invalid_id_step = client.post(f"/{invalid_id}/run-step", data=json.dumps(query_single_step), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id_step.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id_step.data | ||
| #run step: error if settings are missing | ||
| empty_query={} | ||
| response_without_settings = client.post(f"/{id}/run-step", data=json.dumps(empty_query), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_without_settings.status_code == 500 # checking the status code | ||
| assert b'expecting settings to be set' in response_without_settings.data | ||
| #run steps: error if instance id does not exist | ||
| query={ | ||
@@ -476,3 +716,36 @@ "settings": { | ||
| } | ||
| response_with_invalid_id_steps = client.post(f"/{invalid_id}/run-steps", data=json.dumps(query), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id_steps.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id_steps.data | ||
| #run steps: error if settings are missing | ||
| query_with_missing_settings={ | ||
| "numberSteps": 20 | ||
| } | ||
| response_with_missing_settings = client.post(f"/{id}/run-steps", data=json.dumps(query_with_missing_settings), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_settings.status_code == 500 # checking the status code | ||
| assert b'expecting settings to be set' in response_with_missing_settings.data | ||
| #run steps: error if number of steps are missing | ||
| query_with_missing_number_of_steps={ | ||
| "settings": { | ||
| "firstManager": { | ||
| "1": { | ||
| "constants": { | ||
| "constant":7.0 | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| } | ||
| response_with_missing_number_of_steps = client.post(f"/{id}/run-steps", data=json.dumps(query_with_missing_number_of_steps), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_missing_number_of_steps.status_code == 500 # checking the status code | ||
| assert b'expecting a number of steps to be provided in the body as a json' in response_with_missing_number_of_steps.data | ||
| #run steps: error if request is not json | ||
| response_with_not_json = client.post('/' + id + '/run-steps', data=query, headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_not_json.status_code == 500 # checking the status code | ||
| assert b'please pass the request with content-type application/json' in response_with_not_json.data | ||
| #run steps: valid request | ||
| response = client.post('/' + id + '/run-steps', data=json.dumps(query), content_type = 'application/json',headers={"Authorization": f"Bearer {token}"}) | ||
@@ -484,6 +757,40 @@ assert response.status_code == 200, "run-steps response should be 200" | ||
| #flat session results: error if instance id does not exist | ||
| response_with_invalid_id_flat = client.get(f"/{invalid_id}/flat-session-results", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id_flat.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id_flat.data | ||
| #flat session results: valid request | ||
| response = client.get(f"/{id}/flat-session-results", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200, "flat-session-results response should be 200" | ||
| #session results: error if instance id does not exist | ||
| response_with_invalid_id_session = client.get(f"/{invalid_id}/session-results", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id_session.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id_session.data | ||
| #session results: valid request | ||
| response = client.get(f"/{id}/session-results", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200, "session-results response should be 200" | ||
| #stream steps: error if instance id does not exists | ||
| response_stream_with_invalid_id = client.post(f"/{invalid_id}/stream-steps", data=json.dumps(query), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_stream_with_invalid_id.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_stream_with_invalid_id.data | ||
| #stream steps: error if steps are missing | ||
| response_stream_without_settings= client.post(f"/{id}/stream-steps", data=json.dumps(empty_query), content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_stream_without_settings.status_code == 500 # checking the status code | ||
| assert b'expecting settings to be set' in response_stream_without_settings.data | ||
| #end session: error if instance id does not exist | ||
| response_with_invalid_id_end = client.post(f"/{invalid_id}/end-session", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response_with_invalid_id_end.status_code == 500 # checking the status code | ||
| assert b'expecting a valid instance id to be given' in response_with_invalid_id_end.data | ||
| #end session: valid request | ||
| response = client.post(f"/{id}/end-session", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
| assert response.status_code == 200, "end-session response should be 200" | ||
| #stop instance | ||
| response = client.post(f"/{id}/stop-instance", content_type='application/json',headers={"Authorization": f"Bearer {token}"}) | ||
@@ -568,3 +875,2 @@ assert response.status_code == 200, "stop-instance response should be 200" | ||
| def test_stream_steps_lock(app, client): | ||
@@ -571,0 +877,0 @@ |
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
827236
2.19%15664
1.95%