Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest integration #20

Open
radiac opened this issue Sep 25, 2024 · 1 comment
Open

pytest integration #20

radiac opened this issue Sep 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@radiac
Copy link
Owner

radiac commented Sep 25, 2024

Idea:

from django.db import models
from nanodjango import Django

app = Django()

@app.admin
class CountLog(models.Model):
    # Standard Django model, registered with the admin site
    timestamp = models.DateTimeField(auto_now_add=True)

@app.route("/")
def count(request):
    # Standard Django function view
    CountLog.objects.create()
    return f"<p>Number of page loads: {CountLog.objects.count()}</p>"

def test_count():
    assert CountLog.objects.count() == 0
    CountLog.objects.create()
    assert CountLog.objects.count() == 1

then test with

nanodjango test counter.py
@radiac
Copy link
Owner Author

radiac commented Sep 27, 2024

@marcgibbons is looking at this in #28

@radiac radiac assigned radiac and unassigned radiac Sep 27, 2024
@radiac radiac added the enhancement New feature or request label Sep 27, 2024
@radiac radiac moved this from Ready to Implemented in radiac's open source tasks Sep 27, 2024
@radiac radiac moved this from Implemented to In progress in radiac's open source tasks Sep 27, 2024
@radiac radiac removed their assignment Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In progress
Development

No branches or pull requests

1 participant