def ready_to_finish(self): """ Returns true if reservation is ready to be finished """ from metrocar.cars.models import Parking if self.finished or self.ended is not None: return True if self.started is None: return False if not self.car.dedicated_parking_only: # cars which doesn't have dedicated parking are little trouble # as we can't rightfully decide if their reservation can be # finished # => they are collected by reservation deamon return False elif settings.GEO_ENABLED: # is there a Parking that contains car's last_position? return (self.car > maybe | get_car_last_position | X['location'] | 'POINT ({0} {1})' | xcurry(Parking.objects.filter, polygon__contains=X) | X.exists())
def test_should_raise_error_when_not_given_an_argument(self): # -- when created with a placeholder xf = xcurry(dummy, something=X) with pytest.raises(ValueError): xf()
def test_x_destructuring(self): xf = xcurry(dummy, X['name'], number=X['number']) d = {'name': "Fred", 'number': 42, 'something': 'else'} assert xf(d) == (('Fred', ), {'number': 42})
def test_name(self): xf = xcurry(dummy, X, 3, something=X['something']) assert xf.__name__ == "dummy(X, 3, something=X['something'])"
def test_x_placeholder(self): xf = xcurry(dummy, X, 2) assert xf(1) == ((1, 2), {})
def test_x_kw_placeholder(self): xf = xcurry(dummy, kwarg=X) assert xf(1) == ((), {'kwarg': 1})
def test_should_behave_like_partial(self): xf = xcurry(dummy, 1, kwarg='kwarg') assert xf(2, foo='bar') == ((1, 2), {'kwarg': 'kwarg', 'foo': 'bar'})
def test_name(self): xf = xcurry(dummy, X, 3, something=X["something"]) assert xf.__name__ == "dummy(X, 3, something=X['something'])"
def test_x_destructuring(self): xf = xcurry(dummy, X["name"], number=X["number"]) d = {"name": "Fred", "number": 42, "something": "else"} assert xf(d) == (("Fred",), {"number": 42})
def test_x_kw_placeholder(self): xf = xcurry(dummy, kwarg=X) assert xf(1) == ((), {"kwarg": 1})
def test_should_behave_like_partial(self): xf = xcurry(dummy, 1, kwarg="kwarg") assert xf(2, foo="bar") == ((1, 2), {"kwarg": "kwarg", "foo": "bar"})