Esempio n. 1
0
    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())
Esempio n. 2
0
 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()
Esempio n. 3
0
 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})
Esempio n. 4
0
 def test_name(self):
     xf = xcurry(dummy, X, 3, something=X['something'])
     assert xf.__name__ == "dummy(X, 3, something=X['something'])"
Esempio n. 5
0
 def test_x_placeholder(self):
     xf = xcurry(dummy, X, 2)
     assert xf(1) == ((1, 2), {})
Esempio n. 6
0
 def test_x_kw_placeholder(self):
     xf = xcurry(dummy, kwarg=X)
     assert xf(1) == ((), {'kwarg': 1})
Esempio n. 7
0
 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()
Esempio n. 8
0
 def test_should_behave_like_partial(self):
     xf = xcurry(dummy, 1, kwarg='kwarg')
     assert xf(2, foo='bar') == ((1, 2), {'kwarg': 'kwarg', 'foo': 'bar'})
Esempio n. 9
0
 def test_name(self):
     xf = xcurry(dummy, X, 3, something=X["something"])
     assert xf.__name__ == "dummy(X, 3, something=X['something'])"
Esempio n. 10
0
 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})
Esempio n. 11
0
 def test_x_kw_placeholder(self):
     xf = xcurry(dummy, kwarg=X)
     assert xf(1) == ((), {"kwarg": 1})
Esempio n. 12
0
 def test_x_placeholder(self):
     xf = xcurry(dummy, X, 2)
     assert xf(1) == ((1, 2), {})
Esempio n. 13
0
 def test_should_behave_like_partial(self):
     xf = xcurry(dummy, 1, kwarg="kwarg")
     assert xf(2, foo="bar") == ((1, 2), {"kwarg": "kwarg", "foo": "bar"})