def test_importer(self):
        user = User(db_users.get_or_create(1, "Tester", new_user_data={
            "display_name": "test user",
        }))
        review = db_review.create(
            user_id=user.id,
            entity_id="e7aad618-fa86-3983-9e77-405e21796eca",
            entity_type="release_group",
            text="Testing",
            rating=5,
            is_draft=False,
            license_id=self.license["id"],
        )

        # Make dumps and delete entities
        self.runner.invoke(dump_manager.public, ['--location', self.tempdir])
        archives = get_archives(self.tempdir)
        db_review.delete(review['id'])
        db_users.delete(user.id)
        self.assertEqual(db_users.total_count(), 0)
        self.assertEqual(db_review.get_count(), 0)

        # Import dumps - cbdump.tar.bz2 and cbdump-reviews-all.tar.bz2 and check if data imported properly
        self.runner.invoke(dump_manager.importer, [archives['cbdump.tar.bz2']])
        self.assertEqual(db_users.total_count(), 1)

        self.runner.invoke(dump_manager.importer, [archives['cbdump-reviews-all.tar.bz2']])
        self.assertEqual(db_review.get_count(), 1)
 def test_get_count(self):
     count = db_review.get_count()
     self.assertEqual(count, 0)
     db_review.create(
         user_id=self.user.id,
         entity_id="e7aad618-fa86-3983-9e77-405e21796eca",
         entity_type="release_group",
         rating=5,
         is_draft=False,
         license_id=self.license["id"],
     )
     count = db_review.get_count(is_draft=False, is_hidden=False)
     self.assertEqual(count, 1)
 def test_get_count(self):
     count = db_review.get_count()
     self.assertEqual(count, 0)
     db_review.create(
         user_id=self.user.id,
         entity_id="e7aad618-fa86-3983-9e77-405e21796eca",
         entity_type="release_group",
         rating=5,
         is_draft=False,
         license_id=self.license["id"],
     )
     count = db_review.get_count(is_draft=False, is_hidden=False)
     self.assertEqual(count, 1)
Exemple #4
0
def index():
    # Popular reviews
    popular_reviews = db_review.get_popular(6)
    for review in popular_reviews:
        # Preparing text for preview
        preview = markdown(review['text'], safe_mode="escape")
        review['preview'] = ''.join(BeautifulSoup(preview, "html.parser").findAll(text=True))

    # Recent reviews
    recent_reviews, _ = db_review.list_reviews(sort='created', limit=9)

    # Statistics
    review_count = format_number(db_review.get_count(is_draft=False))
    user_count = format_number(db_users.total_count())

    return render_template('index/index.html', popular_reviews=popular_reviews, recent_reviews=recent_reviews,
                           reviews_total=review_count, users_total=user_count)
Exemple #5
0
def index():
    # Popular reviews
    popular_reviews = db_review.get_popular(6)
    for review in popular_reviews:
        # Preparing text for preview
        preview = markdown(review['text'], safe_mode="escape")
        review['preview'] = ''.join(BeautifulSoup(preview, "html.parser").findAll(text=True))

    # Recent reviews
    recent_reviews, _ = db_review.list_reviews(sort='published_on', limit=9)

    # Statistics
    review_count = format_number(db_review.get_count(is_draft=False))
    user_count = format_number(db_users.total_count())

    return render_template('index/index.html', popular_reviews=popular_reviews, recent_reviews=recent_reviews,
                           reviews_total=review_count, users_total=user_count)