Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_total_count(self):
        count = db_users.total_count()
        self.assertEqual(count, 3)

        db_users.get_or_create(4, "user1", new_user_data={
            "display_name": "user_1",
        })
        count = db_users.total_count()
        self.assertEqual(count, 4)
Ejemplo n.º 3
0
    def test_total_count(self):
        count = db_users.total_count()
        self.assertEqual(count, 3)

        user3 = db_users.get_or_create("user1",
                                       new_user_data={
                                           "display_name": "user_1",
                                       })
        count = db_users.total_count()
        self.assertEqual(count, 4)
Ejemplo n.º 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)
Ejemplo n.º 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)