20130507 (Tuesday, 07 May 2013)

  • Worked on the docstring of lino.modlib.accounts.utils.
  • Adapted the test suite to yesterdays’s changes (new column bailiff in in welfare.debts.Entries.

Cannot resolve keyword ‘watched_user’ into field

A request to /restful/cal/PanelEvents?sd=05.05.2013&ed=11.05.2013&tv=true (i.e. clicking the “Team View” button in the calendar panel) caused a FieldError “Cannot resolve keyword ‘watched_user’ into field. Choices are: id, team, user”.

The bug was there since 2013-03-20.

Fixing the bug is easy, but how to write a testcase for this?

This is the occasion for a new style of test cases: test cases that use a django.test.Client, but on the project demo database (and not on a test database as the Django test runner creates it). The advantage is that they access the existing demo database and thus don’t need to populate it (load the demo fixtures) for each test run.

One limitation of these cases is of course that they may not modify the database.

It took me some time to understand how easy it actually is: I just wrote a module lino.projects.presto.settings.doctest, then wrote the following code snippet directly into my blog entry:

>>> import os
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'lino_presto.projects.std.settings.doctests'
>>> from lino.api.shell import *
>>> from django.test import Client
>>> client = Client()
>>> url = '/restful/extensible/PanelEvents?sd=05.05.2013&ed=11.05.2013&tv=true'
>>> res = client.get(url, REMOTE_USER='robin')
>>> print res.status_code

To run this test, I added the following to the project test suite:

class BlogTests(LinoTestCase):
    def test_20130507(self):

The effect is that python setup.py test or python setup.py test -s tests.BlogTests.test_20130507 will test the above code.

Writing this test case took me several hours (because as i said this was a new system), but then I fixed the bug in a few minutes.

Because the run_simple_doctests is run in a separate subprocess, it has its own Python interpreter and thus I can use it for as many Django projects as I want (one project per .rst file).

Now I can remove the following item from my todo list…

  • write unit tests to test the bootstrap ui. The best place would be a tested document with a Django test client. But how to instantiate a Django test client from a testcase which does not use a test database but the project’s demo database?

… by writing a few lines of code:

>>> url = '/bs3/products/Products'
>>> res = client.get(url, REMOTE_USER='robin')
>>> print res.status_code

(Above test is now covered in lino.tested.presto)

New version numbers

The release of 2013-05-05 is now a few days in production, time to increase the version numbers.

Project Old version New version
atelier – A collection of tools for software artists 0.0.1 0.0.2
djangosite – A server startup signal for Django 0.1.3 0.1.4
north – Another way to migrate Django databases 0.1.3 0.1.4
lino – A framework for writing desktop-like web applications using Django and ExtJS 1.6.6 1.6.7
lino_welfare – A Lino application for Belgian Public Welfare Centres 1.1.3 1.1.4
lino_patrols – A Lino application for managing patrols 0.0.1 0.0.2

VirtualBox Windows guest cannot see shared folders

I discovered the solution for one problem: I had the network adapter configured as “NAT”, but what I wanted was “Bridged”.

The other problem remains: the Windows guest doesnt see any host named “vboxsrv”.

Observation: The services manager says that “VirtualBox Guest Additions Service” ist not started. And when I start it, it says “Could not start the VirtualBox Guest Additions Service service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion.”

Edit 20130509 : the solution for this was to find two virtual devices in Windows device manager which were disabled. Enable them, then restart the VM.