<commit_before># -*- coding: utf-8 -*-
"""Django page CMS command tests suite module."""
from pages.models import Page, Content, PageAlias
from pages.tests.testcase import TestCase
from django.core.management import call_command
from django.test import LiveServerTestCase
import json

class CommandTestCase(TestCase, LiveServerTestCase):
    """Django page CMS command tests suite class."""

    def test_pull(self):
        """Pull command"""
        self.new_page(content={'title': 'pull-page', 'slug': 'pull-slug'})
        url =  self.live_server_url + '/pages/api/'
        filename = '/tmp/test'
        call_command('pages_pull', 'admin:b', filename=filename, host=url, verbosity=0)
        with open(filename, "r") as f:
            data = f.read()
            pages = json.loads(data)
            for content in pages['results'][0]['content_set']:
                 self.assertTrue(content['body'] in ['pull-page', 'pull-slug'])

    def test_push(self):
        """Push command"""
        url =  self.live_server_url + '/pages/api/'
        page = self.new_page(content={'title': 'pull-page', 'slug': 'pull-slug'})
        call_command('pages_pull', 'admin:b', filename='/tmp/test', host=url, verbosity=0)
        page.delete()
        self.assertEqual(Page.objects.all().count(), 0)
        call_command('pages_push', 'admin:b', filename='/tmp/test', host=url, verbosity=0)
        self.assertEqual(Page.objects.all().count(), 1)
<commit_msg>Improve coverage<commit_after># -*- coding: utf-8 -*-
"""Django page CMS command tests suite module."""
from pages.models import Page, Content, PageAlias
from pages.tests.testcase import TestCase
from django.core.management import call_command
from django.test import LiveServerTestCase
import json

class CommandTestCase(TestCase, LiveServerTestCase):
    """Django page CMS command tests suite class."""

    def test_pull(self):
        """Pull command"""
        self.new_page(content={'title': 'pull-page', 'slug': 'pull-slug'})
        url =  self.live_server_url + '/pages/api/'
        filename = '/tmp/test'
        call_command('pages_pull', 'admin:b', filename=filename, host=url, verbosity=0)
        with open(filename, "r") as f:
            data = f.read()
            pages = json.loads(data)
            for content in pages['results'][0]['content_set']:
                 self.assertTrue(content['body'] in ['pull-page', 'pull-slug'])

    def test_push(self):
        """Push command"""
        url =  self.live_server_url + '/pages/api/'
        page1 = self.new_page(content={'title': 'pull-page', 'slug': 'pull-slug'})
        page2 = self.new_page(content={'title': 'pull-page-2', 'slug': 'pull-slug-2'})
        call_command('pages_pull', 'admin:b', filename='/tmp/test', host=url, verbosity=0)
        page1.delete()
        self.assertEqual(Page.objects.all().count(), 1)
        call_command('pages_push', 'admin:b', filename='/tmp/test', host=url, verbosity=0)
        self.assertEqual(Page.objects.all().count(), 2)

{'fraction_non_alphanumeric': 0.16221628838451269, 'fraction_numerical': 0.006341789052069426, 'mean_word_length': 3.263157894736842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6859990', 'n_tokens_mistral': 899, 'n_tokens_neox': 906, 'n_words': 210}