Ejemplo n.º 1
0
    def test_validation_2_1(self):
        """ test_validation_2_1
        Filter 2 against filter_validation 1
        """
        saved = SavedFilter(self.lc, 2)

        # Get loan list
        response = self.lc.session.get('/filter_validation', query={'id': 1})
        json_response = response.json()
        self.loan_list = json_response['loanFractions']

        # Validate, should not fail
        saved.validate(self.loan_list)
Ejemplo n.º 2
0
    def test_validation_2_3(self):
        """ test_validation_3
        Filter 2 against filter_validation 3
        """
        saved = SavedFilter(self.lc, 2)

        # Get loan list
        response = self.lc.session.get('/filter_validation', query={'id': 3})
        json_response = response.json()
        self.loan_list = json_response['loanFractions']

        # Validate, should fail on 'exclude_invested'
        try:
            saved.validate(self.loan_list)
            assert False, 'Test should fail on grade'
        except FilterValidationError as e:
            print(e.criteria)
            self.assertTrue(matches('grade', e.criteria))
Ejemplo n.º 3
0
    def get_saved_filters(self):
        """
        Get a list of all the saved search filters you've created on lendingclub.com

        Returns
        -------
        list
            List of :class:`lendingclub.filters.SavedFilter` objects
        """
        return SavedFilter.all_filters(self)
Ejemplo n.º 4
0
    def get_saved_filters(self):
        """
        Get a list of all the saved search filters you've created on lendingclub.com

        Returns
        -------
        list
            List of :class:`lendingclub.filters.SavedFilter` objects
        """
        return SavedFilter.all_filters(self)
Ejemplo n.º 5
0
    def get_saved_filter(self, filter_id):
        """
        Load a single saved search filter from the site by ID

        Parameters
        ----------
        filter_id : int
            The ID of the saved filter

        Returns
        -------
        SavedFilter
            A :class:`lendingclub.filters.SavedFilter` object or False
        """
        return SavedFilter(self, filter_id)
Ejemplo n.º 6
0
    def __getitem__(self, key):
        """
        Attempts to a value from one of the dictionaries
        """
        if key in self.investing:
            if key == 'filters' and self.investing['filter_id'] and type(
                    self.investing['filters']) is not SavedFilter:
                self.investing['filters'] = SavedFilter(
                    self.investor.lc, self.investing['filter_id'])

            return self.investing[key]
        if key in self.user_settings:
            return self.user_settings[key]
        if key in self.auth:
            return self.auth[key]
        return None
Ejemplo n.º 7
0
    def __getitem__(self, key):
        """
        Attempts to a value from one of the dictionaries
        """
        if key in self.investing:

            # Load saved filter by ID
            if key == 'filters' and 'filter_id' in self.investing and self.investing['filter_id'] and type(self.investing['filters']) is not SavedFilter:
                try:
                    self.investing['filters'] = SavedFilter(self.investor.lc, self.investing['filter_id'])
                except Exception:
                    self.investing['filters'] = None

            return self.investing[key]
        if key in self.user_settings:
            return self.user_settings[key]
        if key in self.auth:
            return self.auth[key]
        return None
Ejemplo n.º 8
0
    def test_get_saved_filters(self):
        saved = SavedFilter(self.lc, 1)

        self.assertEqual(saved.name, 'Filter 1')
        self.assertEqual(saved.id, 1)
        self.assertNotEqual(saved.search_string(), None)
Ejemplo n.º 9
0
    def test_get_all_filters(self):
        filters = SavedFilter.all_filters(self.lc)

        self.assertEqual(len(filters), 2)
        self.assertEqual(filters[0].name, 'Filter 1')