import pytest

from django.test import Client
from django.utils import timezone

pytestmark = pytest.mark.django_db


class TestRendererFormView:

    def test_get_empty_form(self, client: Client):
        response = client.get('/renderer/')
        assert response.status_code == 200
        assert response.context['form']['date'].value() \
               == timezone.now().strftime('%Y-%m-%d')

    def test_render(self, client: Client):
        response = client.post('/renderer/', data={
            'title': 'Sample Title',
            'date': '2009-11-15',
            'render_content': '# Example'
        })
        assert b'Sample Title' in response.content
        assert b'15.11.2009' in response.content
        assert b'Example' in response.content

