def test_storing_retrieving_splits(self, mocker): """Test storing and retrieving splits works.""" storage = InMemorySplitStorage() split = mocker.Mock(spec=Split) name_property = mocker.PropertyMock() name_property.return_value = 'some_split' type(split).name = name_property storage.put(split) assert storage.get('some_split') == split assert storage.get_split_names() == ['some_split'] assert storage.get_all_splits() == [split] assert storage.get('nonexistant_split') is None storage.remove('some_split') assert storage.get('some_split') is None
def test_get_all_splits(self, mocker): """Test retrieving a list of all split names.""" split1 = mocker.Mock() name1_prop = mocker.PropertyMock() name1_prop.return_value = 'split1' type(split1).name = name1_prop split2 = mocker.Mock() name2_prop = mocker.PropertyMock() name2_prop.return_value = 'split2' type(split2).name = name2_prop storage = InMemorySplitStorage() storage.put(split1) storage.put(split2) all_splits = storage.get_all_splits() assert next(s for s in all_splits if s.name == 'split1') assert next(s for s in all_splits if s.name == 'split2')