示例#1
0
    def test_scores_things(self, score_listing):
        """Should score each fetched listing."""
        fetch_detail(*self.listing_ids)

        for listing in listings():
            listing['users'] = 3
            score_listing.assert_any_call(listing)
示例#2
0
    def test_dont_store_unviewed(self, score_listing):
        """Should not store data for unviewed listings."""
        self.get_listing_data.return_value = [
            {
                'listing_id': '3',
                'materials': ['fart'],
                'state': 'active',
                'quantity': 1,
                'views': 0,
            },
        ]

        fetch_detail('3')

        assert_does_not_exist('3')
        assert score_listing.called == False
示例#3
0
    def test_destroy_unviewed(self):
        """Should delete everything about an unviewed listing."""
        self.get_listing_data.return_value = [
            {
                'listing_id': '3',
                'materials': ['fart'],
                'state': 'active',
                'quantity': 1,
                'views': 0,
            },
        ]

        store_fake_data('3')

        fetch_detail('3')

        assert_does_not_exist('3')
示例#4
0
    def test_fetch_detail(self, score_listing):
        """Should get and store listing data."""
        result = fetch_detail(*self.listing_ids)

        for listing in listings():
            data = json.loads(r.get('listings.%s.data' % listing['listing_id']))

            assert data.pop('users') == 3
            assert data == listing