def test_get_timestamps(): stream = [ { "concept:name": "Activity A", "time:timestamp": datetime(2021, 4, 30, 9, 0, 0), }, { "concept:name": "Activity B", "time:timestamp": datetime(2021, 4, 30, 10, 0, 0), }, { "concept:name": "Activity C", "time:timestamp": datetime(2021, 5, 1, 9, 0, 0), }, ] case = Case("test_get_timestamps") case.add_event(stream[0]) case.add_event(stream[1]) case.add_event(stream[2]) assert case.get_timestamps() == [ datetime(2021, 4, 30, 9, 00, 00), datetime(2021, 4, 30, 10, 00, 00), datetime(2021, 5, 1, 9, 00, 00), ]
def test_set_activity(): activity = Activity( 'activity1', datetime.strptime('2015/05/10 08:22:53.000', '%Y/%m/%d %H:%M:%S.%f')) case = Case('2') case.set_activity(activity.name, activity.timestamp) assert isinstance(case.activities[0], Activity) assert case.activities[0].name == 'activity1' assert case.activities[0].timestamp == datetime(2015, 5, 10, 8, 22, 53)
def test_add_event(): stream = [{ "concept:name": "Activity A", "time:timestamp": datetime(2021, 4, 30, 9, 0, 0), }] case = Case("test_add_event") case.add_event(stream[0]) assert len(case.events) == 1 assert case.events[0]["concept:name"] == "Activity A" assert case.events[0]["time:timestamp"] == datetime(2021, 4, 30, 9, 0, 0)
def test_no_value(): with pytest.raises(Exception): assert Case()
import numpy as np from datetime import datetime from cdesf2.data_structures.case import Case from cdesf2.data_structures.activity import Activity import pytest def test_case(): case = Case('1') assert isinstance(case, Case) def test_initial_value(): case = Case('1') assert isinstance(case.id, str) assert case.id == '1' assert isinstance(case.activities, list) assert case.activities == [] assert case.graph_distance is np.nan assert case.time_distance is np.nan def test_no_value(): with pytest.raises(Exception): assert Case() def test_set_activity(): activity = Activity( 'activity1', datetime.strptime('2015/05/10 08:22:53.000', '%Y/%m/%d %H:%M:%S.%f'))
import numpy as np from datetime import datetime from cdesf2.data_structures.case import Case import pytest def test_case(): case = Case("1") assert isinstance(case, Case) def test_initial_value(): case = Case("1") assert case.id == "1" assert len(case.events) == 0 assert len(case.distances) == 0 # This test is replaced by the static analysis of the Python compiler. # def test_no_value(): # with pytest.raises(Exception): # assert Case() def test_add_event(): stream = [{ "concept:name": "Activity A", "time:timestamp": datetime(2021, 4, 30, 9, 0, 0), }]