django test by perfecto

This commit is contained in:
pErfEcto2
2023-05-04 11:31:11 +03:00
parent d0d2a37782
commit d8897febc5
36 changed files with 298 additions and 0 deletions
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class PollsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'polls'
@@ -0,0 +1,5 @@
from django import forms
class TestForm(forms.Form):
test_data = forms.CharField(label="test data", max_length=128)
@@ -0,0 +1,32 @@
# Generated by Django 4.2.1 on 2023-05-04 06:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Question',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('question_text', models.CharField(max_length=256)),
('pub_date', models.DateTimeField(verbose_name='date published')),
],
),
migrations.CreateModel(
name='Choice',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('choice_text', models.CharField(max_length=256)),
('votes', models.IntegerField(default=0)),
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.question')),
],
),
]
@@ -0,0 +1,12 @@
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=256)
pub_date = models.DateTimeField("date published")
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=256)
votes = models.IntegerField(default=0)
@@ -0,0 +1,3 @@
h1 {
color: green;
}
@@ -0,0 +1,11 @@
<!DOCTYPE <html>
<html>
<head>
{% load static %}
<link rel="stylesheet" href="{% static 'polls/style.css' %}">
<title>TEST</title>
</head>
<body>
<h1>{{text}}</h1>
</body>
</html>
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
@@ -0,0 +1,8 @@
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
path("test", views.test, name="other")
]
@@ -0,0 +1,15 @@
from django.http import HttpResponse
from django.shortcuts import render
# from db_get_data import exec_query
def index(request):
context = {
"text": "test"
}
return HttpResponse(render(request, "polls/index.html", context))
def test(req):
return HttpResponse("test")