Skip to content

Commit 7ebabfe

Browse files
Align repo files and test settings with speed.python.org
1 parent e22830c commit 7ebabfe

7 files changed

Lines changed: 52 additions & 13 deletions

File tree

‎.gitignore‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
.DS_Store
55
*.db
66
sample_project/repos/*
7+
speed_python/repos/*
78
speed_pypy/repos/*
9+
speed_python/sitestatic/*
10+
speed_python/secret_key
811
override
912
build
1013
dist
11-
codespeed.egg-info/
12-
14+
*.egg-info
15+
.venv*/
16+
speed_python/local_settings.py

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ The codespeed installation can now be accessed by navigating to `http://localhos
5050
modify `sample_project/settings.py` and set `DEBUG = False`.
5151
[`sample_project/README.md`](https://github.com/tobami/codespeed/tree/master/sample_project/README.md) also describes some production settings.
5252

53+
### Running the tests
54+
55+
The test suite uses its own site-independent settings module:
56+
57+
python manage.py test codespeed --settings=codespeed.tests.settings
58+
5359
## Codespeed configuration
5460

5561
### Using the provided test data

‎codespeed/tests/settings.py‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
"""Django settings for running the Codespeed test suite.
2+
3+
Site independent: no site package is involved, so the suite exercises the
4+
``codespeed`` app on its own. Site packages such as ``speed_pypy`` run their
5+
tests under these settings too and override what they need per test case.
6+
7+
Usage::
8+
9+
python manage.py test codespeed --settings=codespeed.tests.settings
10+
"""
111
import os
2-
from codespeed.settings import *
12+
13+
from codespeed.settings import * # noqa: F401,F403
14+
15+
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
16+
17+
DEBUG = False
318

419
DATABASES = {
520
'default': {
@@ -10,8 +25,9 @@
1025

1126
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
1227
SECRET_KEY = 'test-secret-key-not-for-production'
13-
USE_TZ = False
28+
USE_TZ = True
1429
TIME_ZONE = 'UTC'
30+
USE_I18N = False
1531

1632
INSTALLED_APPS = (
1733
'django.contrib.auth',
@@ -31,12 +47,13 @@
3147
'django.contrib.messages.middleware.MessageMiddleware',
3248
)
3349

34-
ROOT_URLCONF = 'speed_pypy.urls'
50+
ROOT_URLCONF = 'codespeed.urls'
3551

3652
TEMPLATES = [
3753
{
3854
'BACKEND': 'django.template.backends.django.DjangoTemplates',
39-
'DIRS': [],
55+
# Site-style template overrides the tests check for
56+
'DIRS': [os.path.join(TESTS_DIR, 'templates')],
4057
'APP_DIRS': True,
4158
'OPTIONS': {
4259
'context_processors': [
@@ -50,4 +67,10 @@
5067
]
5168

5269
STATIC_URL = '/static/'
70+
71+
# Codespeed clones repositories here when commit logs are requested.
5372
REPOSITORY_BASE_PATH = '/tmp/codespeed-test-repos'
73+
74+
CACHES = {
75+
'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'},
76+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "codespeed/base.html" %}
2+
3+
{# Site-level override, used to verify that a site can customise the title #}
4+
{% block title %}
5+
My Own Title
6+
{% endblock %}

‎codespeed/tests/test_views.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from django.test import TestCase, override_settings
77
from django.urls import reverse
8+
from django.utils import timezone
89

910
from codespeed.models import (Project, Benchmark, Revision, Branch, Executable,
1011
Environment, Result, Report)
@@ -77,7 +78,7 @@ def test_add_non_default_result(self):
7778
r = Revision.objects.get(commitid='23', branch=branch)
7879

7980
# Tweak the resolution down to avoid failing over very slight differences:
80-
self.assertEqual(r.date, revision_date)
81+
self.assertEqual(r.date, timezone.make_aware(revision_date))
8182

8283
i = Executable.objects.get(name='myexe O3 64bits')
8384
b = Benchmark.objects.get(name='float')
@@ -87,7 +88,7 @@ def test_add_non_default_result(self):
8788
benchmark=b,
8889
environment=e
8990
)
90-
self.assertEqual(res.date, result_date)
91+
self.assertEqual(res.date, timezone.make_aware(result_date))
9192
self.assertEqual(res.std_dev, 1.11111)
9293
self.assertEqual(res.val_max, 2)
9394
self.assertEqual(res.val_min, 1)
@@ -408,7 +409,7 @@ def test_timeline(self):
408409
response = self.client.get(path)
409410
self.assertEqual(response.status_code, 200)
410411
responsedata = response.content.decode()
411-
self.assertIn("MyProject's Speed Center: Timeline", responsedata)
412+
self.assertIn('My Own Title\n: Timeline', responsedata)
412413

413414
def test_gettimelinedata(self):
414415
"""Test that gettimelinedata returns correct timeline data
@@ -443,7 +444,7 @@ def test_gettimelinedata(self):
443444
"There are 2 datapoints")
444445
self.assertEqual(
445446
responsedata['timelines'][0]['branches']['master']['1:1'][1],
446-
[u'2011/04/13 17:04:22 ', 2000.0, 1.11111, u'2', u'', u'master', u''])
447+
[u'2011/04/13 17:04:22 +0000', 2000.0, 1.11111, u'2', u'', u'master', u''])
447448

448449

449450
@override_settings(ALLOW_ANONYMOUS_POST=True)

‎manage.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "speed_pypy.settings")
66

77
from django.core.management import execute_from_command_line
8-
execute_from_command_line(sys.argv)
98

9+
execute_from_command_line(sys.argv)

‎setup.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
license='GNU Lesser General Public License version 2.1',
1111
keywords=['benchmarking', 'visualization'],
1212
install_requires=['django', 'isodate', 'matplotlib'],
13-
packages=find_packages(exclude=['ez_setup', 'sample_project']),
13+
packages=find_packages(exclude=['ez_setup', 'sample_project', 'speed_python', 'speed_pypy']),
1414
long_description='README.md',
1515
long_description_content_type="text/markdown",
1616
description='A web application to monitor and analyze the performance of your code',
@@ -32,4 +32,3 @@
3232
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
3333
]
3434
)
35-

0 commit comments

Comments
 (0)