def test_kill_locally(self): """Test kill local.""" uwsgi = get_uwsgi(True) storage = UWSGISplitStorage(uwsgi) split = Split('some_split', 123456789, False, 'some', 'traffic_type', 'ACTIVE', 1) storage.put(split) storage.set_change_number(1) storage.kill_locally('test', 'default_treatment', 2) assert storage.get('test') is None storage.kill_locally('some_split', 'default_treatment', 0) assert storage.get('some_split').change_number == 1 assert storage.get('some_split').killed is False assert storage.get('some_split').default_treatment == 'some' storage.kill_locally('some_split', 'default_treatment', 3) assert storage.get('some_split').change_number == 3
def test_store_retrieve_split(self, mocker): """Test storing and retrieving splits.""" uwsgi = get_uwsgi(True) storage = UWSGISplitStorage(uwsgi) from_raw_mock = self._get_from_raw_mock(mocker) mocker.patch('splitio.models.splits.from_raw', new=from_raw_mock) raw_split = {'name': 'some_split', 'trafficTypeName': 'user'} split = from_raw_mock(raw_split) from_raw_mock.reset_mock() # clear mock calls so they don't interfere with the testing itself. storage.put(split) retrieved = storage.get('some_split') assert retrieved.name == split.name and retrieved.traffic_type_name == split.traffic_type_name assert from_raw_mock.mock_calls == [mocker.call(raw_split)] assert split.to_json.mock_calls == [mocker.call()] assert storage.get('nonexistant_split') is None storage.remove('some_split') assert storage.get('some_split') == None
def test_store_retrieve_split(self, mocker): """Test storing and retrieving splits.""" uwsgi = get_uwsgi(True) storage = UWSGISplitStorage(uwsgi) split = mocker.Mock(spec=Split) split.to_json.return_value = '{}' split_name = mocker.PropertyMock() split_name.return_value = 'some_split' type(split).name = split_name storage.put(split) from_raw_mock = mocker.Mock() from_raw_mock.return_value = 'ok' mocker.patch('splitio.models.splits.from_raw', new=from_raw_mock) retrieved = storage.get('some_split') assert retrieved == 'ok' assert from_raw_mock.mock_calls == [mocker.call('{}')] assert split.to_json.mock_calls == [mocker.call()] assert storage.get('nonexistant_split') is None storage.remove('some_split') assert storage.get('some_split') == None