"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)

@@ -1,250 +1,1369 @@
-%22%22%22%0AThis file demonstrates writing tests using the unittest module. These will pass%0Awhen you run %22manage.py test%22.%0A%0AReplace this with more appropriate tests for your application.%0A%22%22%22%0A%0Afrom django.test import TestCase%0A%0A%0Aclass SimpleTest(TestCase):
+from django.test import TestCase%0Afrom django.db import connection%0Aimport os%0A%0Afrom vncbrowser.models import Project, Stack%0A%0Aclass SimpleTest(TestCase):%0A    def test_basic_addition(self):%0A        %22%22%22%0A        Tests that 1 + 1 always equals 2.%0A        %22%22%22%0A        self.assertEqual(1 + 1, 2)%0A%0Adef ensure_schema_exists():%0A    %22%22%22%0A    This function will create the CATMAID schema is it doesn't seem to%0A    exist yet (based on the presence or not of the 'project' table.%0A    %22%22%22%0A    cursor = connection.cursor()%0A    # See if the project table has been created:%0A    cursor.execute(%22SELECT count(*) FROM pg_tables WHERE tablename = 'project'%22)%0A    row = cursor.fetchone()%0A    if row%5B0%5D == 1:%0A        return%0A    current_directory = os.path.dirname(os.path.abspath(__file__))%0A    with open(os.path.join(current_directory, %22tables.sql%22)) as fp:%0A        cursor.execute(fp.read())%0A%0Aclass InsertionTest(TestCase):%0A    def setUp(self):%0A        ensure_schema_exists()%0A%0A    def test_project_insertion(self):%0A        %22%22%22%0A        Tests that a project can be inserted, and that the%0A        id is retrievable afterwards.  (This is something that%0A        the custom psycopg2 driver is needed for.)%0A        %22%22%22%0A        p = Project()%0A        p.title = %22Example Project%22%0A        p.comment = %22This is an example project for the Django tests%22%0A        p.save()%0A        self.assertEqual(p.id, 1)%0A
 %0A   
@@ -1368,34 +1368,35 @@
    def test_
-basic_addi
+stack_inser
 tion(self):%0A
@@ -1407,65 +1407,352 @@
     
-%22%22%22%0A        Tests that 1 + 1 always equals 2.%0A        %22%22%22
+s = Stack()%0A        s.title = %22Example Stack%22%0A        s.image_base = %22http://incf.ini.uzh.ch/image-stack-fib/%22%0A        s.trakem2_project = False%0A        s.save()%0A        self.assertEqual(s.id, 1)%0A        # Now try to associate this stack with the project:%0A        p = Project.objects.get(pk=1)%0A        self.assertTrue(p)%0A        p.stacks.add(s)
 %0A   
@@ -1761,30 +1761,38 @@
    self.assertEqual(
-1 + 1, 2
+len(self.stacks)
 )%0A

Add some initial tests, a couple failing for TDD reasons