def test_put_get_activity_record(self, mock_config_with_activitystore): """Method to test creating and getting an individual activity record""" adr1 = ActivityDetailRecord(ActivityDetailType.CODE) adr1.show = True adr1.importance = 100 adr1.add_value("text/plain", "this is a thing" * 1000) adr1.tags = ['tag1', 'tag2'] adr2 = ActivityDetailRecord(ActivityDetailType.RESULT) adr2.show = False adr2.importance = 0 adr2.add_value("text/plain", "another item") adr2.tags = ['tag1', 'tag2'] linked_commit = helper_create_labbook_change(mock_config_with_activitystore[1], 1) ar = ActivityRecord(ActivityType.CODE, show=True, message="added some code", importance=50, linked_commit=linked_commit.hexsha) ar.add_detail_object(adr1) ar.add_detail_object(adr2) assert ar.commit is None # Create Activity Record ar_written = mock_config_with_activitystore[0].create_activity_record(ar) assert ar.commit is not None assert ar.username == 'default' assert ar.email == '*****@*****.**' # Get Note and check stored_ar = mock_config_with_activitystore[0].get_activity_record(ar_written.commit) assert ar.commit == stored_ar.commit assert ar.importance == stored_ar.importance assert ar.linked_commit == stored_ar.linked_commit assert ar.log_str == stored_ar.log_str assert ar.message == stored_ar.message assert ar.show == stored_ar.show assert ar.tags == stored_ar.tags assert ar.type == stored_ar.type assert len(ar._detail_objects) == len(stored_ar._detail_objects) assert ar._detail_objects[0][0] == stored_ar._detail_objects[0][0] assert ar._detail_objects[0][1] == stored_ar._detail_objects[0][1] assert ar._detail_objects[0][2] == stored_ar._detail_objects[0][2] assert ar._detail_objects[0][3].is_loaded is True assert ar._detail_objects[1][3].is_loaded is True assert stored_ar._detail_objects[0][3].is_loaded is False assert stored_ar._detail_objects[1][3].is_loaded is False assert stored_ar.username == 'default' assert stored_ar.email == '*****@*****.**'
def test_put_get_detail_record_with_tags(self, mock_config_with_activitystore): """Test to test storing and retrieving data from the activity detail db""" # Create test values adr1 = ActivityDetailRecord(ActivityDetailType.CODE, action=ActivityAction.CREATE) adr1.show = True adr1.importance = 100 adr1.add_value("text/plain", "first") adr1.tags = ['test1'] adr2 = ActivityDetailRecord(ActivityDetailType.CODE_EXECUTED, action=ActivityAction.EXECUTE) adr2.show = True adr2.importance = 0 adr2.add_value("text/plain", "second") adr2.tags = ['test2', 'test:3'] adr1 = mock_config_with_activitystore[0].put_detail_record(adr1) adr2 = mock_config_with_activitystore[0].put_detail_record(adr2) assert adr1.key is not None assert adr2.key is not None assert type(adr1.key) == str assert type(adr2.key) == str # Load adr1_loaded = mock_config_with_activitystore[0].get_detail_record(adr1.key) adr2_loaded = mock_config_with_activitystore[0].get_detail_record(adr2.key) assert adr1.key == adr1_loaded.key assert adr1.importance == adr1_loaded.importance assert adr1.type == adr1_loaded.type assert adr1.is_loaded == adr1_loaded.is_loaded is True assert adr1.data == adr1_loaded.data assert adr1.tags == adr1_loaded.tags assert adr1.action == adr1_loaded.action == ActivityAction.CREATE assert adr2.key == adr2_loaded.key assert adr2.importance == adr2_loaded.importance assert adr2.type == adr2_loaded.type assert adr2.is_loaded == adr2_loaded.is_loaded is True assert adr2.data == adr2_loaded.data assert adr2.tags == adr2_loaded.tags assert adr2.action == adr2_loaded.action == ActivityAction.EXECUTE