kopia lustrzana https://github.com/wagtail/wagtail
Merge 3ac45db5ab
into 74b5933ae7
commit
0243092b9a
|
@ -16,6 +16,7 @@ mysite/
|
|||
home_page.html
|
||||
__init__.py
|
||||
models.py
|
||||
tests.py
|
||||
search/
|
||||
templates/
|
||||
search/
|
||||
|
@ -97,6 +98,24 @@ The Django settings files are split up into `base.py`, `dev.py`, `production.py`
|
|||
On production servers, we recommend that you only store secrets in ``local.py`` (such as API keys and passwords). This can save you headaches in the future if you are ever trying to debug why a server is behaving badly. If you are using multiple servers which need different settings then we recommend that you create a different ``production.py`` file for each one.
|
||||
```
|
||||
|
||||
### Running and Writing Tests
|
||||
|
||||
When you create a new project using `wagtail start`, there will be a set of basic tests included in the `home/tests.py` file.
|
||||
|
||||
These tests check:
|
||||
|
||||
- If the _root `Page`_ (ID=1) is automatically created.
|
||||
- If the _home `Page`_ is created as a child of the root page.
|
||||
- If a `BlogIndexPage` (or other page types) can be added.
|
||||
|
||||
#### Running the Tests
|
||||
|
||||
To run the tests, navigate to your project folder and run:
|
||||
|
||||
```sh
|
||||
python manage.py test home
|
||||
```
|
||||
|
||||
### Dockerfile
|
||||
|
||||
Location: `/mysite/Dockerfile`
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
from wagtail.test.utils import WagtailPageTestCase
|
||||
from wagtail.models import Page
|
||||
from home.models import HomePage
|
||||
|
||||
class HomeSetUpTests(WagtailPageTestCase):
|
||||
"""
|
||||
Tests steps needed by follow up tests
|
||||
"""
|
||||
|
||||
def test_root_create(self):
|
||||
root_page = Page.objects.get(pk=1)
|
||||
self.assertIsNotNone(root_page)
|
||||
|
||||
def test_homepage_create(self):
|
||||
root_page = Page.objects.get(pk=1)
|
||||
homepage = HomePage(title="Home")
|
||||
root_page.add_child(instance=homepage)
|
||||
self.assertTrue(HomePage.objects.filter(title="Home").exists())
|
||||
|
||||
|
||||
class HomeTests(WagtailPageTestCase):
|
||||
"""
|
||||
Class for testing homepage logic
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the testing environment.
|
||||
"""
|
||||
|
||||
root_page = Page.objects.get(pk=1)
|
||||
self.homepage = HomePage(title='Home')
|
||||
root_page.add_child(instance=self.homepage)
|
||||
|
||||
def test_your_test(self):
|
||||
"""
|
||||
Tests if BlogIndexPage can be created.
|
||||
"""
|
||||
|
||||
raise NotImplementedError("The tests are not implemented yet.")
|
Ładowanie…
Reference in New Issue