Пример #1
0
    def test01(self):
        dbsess = startup()
        be=dbsess.query(Nation).peek("be")
        #qry=be.contacts_by_nation("")
        qry = dbsess.query(Contact,"person.title name",nation=be)
        qry.addColFilter('person',NotEmpty)
        qry.show(columnWidths="12 20")
        #dbc.showQuery(qry,columnWidths="6 10 20")
        #sess.showReport(rpt)
        s = self.getConsoleOutput()
        
        #print s
        
        self.assertEquivalent(s,u"""\
Contacts (nation=Belgium) where 'person' not empty
==================================================
person.title|name
------------+--------------------
Herrn       |Andreas Arens
Monsieur    |Henri Bodard
Herrn       |Emil Eierschal
Frau        |Erna Eierschal
Herrn       |Gerd Großmann
Herrn       |Frédéric Freitag
""")
                         

        dbsess.shutdown()
Пример #2
0
    def test01(self):
        from lino.apps.contacts.contacts_demo import startup
        self.doit(
            startup(), u"""
Estonia is used by 10 rows in Cities
Belgium is used by 9 rows in Cities
Germany is used by 7 rows in Cities
Eupen (be) is used by 7 rows in Contacts
Verviers (be) is used by 1 rows in Contacts
Aachen (de) is used by 1 rows in Contacts
München (de) is used by 1 rows in Contacts
Tallinn (ee) is used by 3 rows in Contacts
Kurtz & Büntig is used by 3 rows in Contacts
Reisebüro Freitag is used by 2 rows in Contacts
Bäckerei Ausdemwald is used by 1 rows in Contacts
Hans Flott is used by 2 rows in Contacts
Mets & puu OÜ is used by 2 rows in Contacts
Andreas Arens is used by 1 rows in Contacts
Anton Ausdemwald is used by 2 rows in Contacts
Emil Eierschal is used by 1 rows in Contacts
Henri Bodard is used by 1 rows in Contacts
Erna Eierschal is used by 1 rows in Contacts
Gerd Großmann is used by 1 rows in Contacts
Frédéric Freitag is used by 2 rows in Contacts
Tõnu Tamm is used by 1 rows in Contacts
Kati Kask is used by 2 rows in Contacts
Klaus Kurtz is used by 1 rows in Contacts
Bruno Büntig is used by 1 rows in Contacts
Hans Flott is used by 1 rows in Contacts
Director is used by 6 rows in Contacts        
        """)
Пример #3
0
    def test01(self):
        dbsess = startup()
        be=dbsess.query(Nation).peek("be")
        #qry=be.contacts_by_nation("")
        qry = dbsess.query(Contact,"person.title name",nation=be)
        qry.addColFilter('person',NotEmpty)
        qry.show(columnWidths="12 20")
        #dbc.showQuery(qry,columnWidths="6 10 20")
        #sess.showReport(rpt)
        s = self.getConsoleOutput()
        
        #print s
        
        self.assertEquivalent(s,u"""\
Contacts (nation=Belgium) where 'person' not empty
==================================================
person.title|name
------------+--------------------
Herrn       |Andreas Arens
Monsieur    |Henri Bodard
Herrn       |Emil Eierschal
Frau        |Erna Eierschal
Herrn       |Gerd Großmann
Herrn       |Frédéric Freitag
""")
                         

        dbsess.shutdown()
Пример #4
0
    def test03(self):
        from lino.apps.ledger.ledger_demo import startup
        self.doit(startup(), u"""\
BEF is used by 8 rows in Contacts
Chair is used by 1 rows in InvoiceLines
Table is used by 1 rows in InvoiceLines
outgoing invoices is used by 1 rows in Invoices
OUT-1 is used by 2 rows in InvoiceLines
Estonia is used by 10 rows in Cities
Belgium is used by 9 rows in Cities
Germany is used by 7 rows in Cities
Eupen (be) is used by 7 rows in Contacts
Verviers (be) is used by 1 rows in Contacts
Aachen (de) is used by 1 rows in Contacts
München (de) is used by 1 rows in Contacts
Tallinn (ee) is used by 3 rows in Contacts
Kurtz & Büntig is used by 3 rows in Contacts
Reisebüro Freitag is used by 2 rows in Contacts
Bäckerei Ausdemwald is used by 1 rows in Contacts
Hans Flott is used by 2 rows in Contacts
Mets & puu OÜ is used by 2 rows in Contacts
Andreas Arens is used by 1 rows in Contacts
Anton Ausdemwald is used by 2 rows in Contacts
Emil Eierschal is used by 1 rows in Contacts
Henri Bodard is used by 1 rows in Contacts
Erna Eierschal is used by 1 rows in Contacts
Gerd Großmann is used by 1 rows in Contacts
Frédéric Freitag is used by 2 rows in Contacts
Tõnu Tamm is used by 1 rows in Contacts
Kati Kask is used by 2 rows in Contacts
Klaus Kurtz is used by 1 rows in Contacts
Bruno Büntig is used by 1 rows in Contacts
Hans Flott is used by 1 rows in Contacts
Director is used by 6 rows in Contacts        
        """)
Пример #5
0
    def test01(self):
        db = startup()
        s1 = ''
        q = db.query(Contact,\
                     "name street city.name",
                     orderBy="name")
        q.addColFilter('city',NotEmpty)
##         for row in q:
##             #print row[0]
##             s1 += str(row[0]) + " "
##             s1 += str(row[1]) + " "
##             s1 += str(row[2]) + "\n"
##         #print s1
##         self.assertEqual(s1,"""\
## Arens None Eupen
## Ausdemwald None Aachen
## Bodard None Verviers
## Eesti Telefon Sõpruse pst. Tallinn
## Eierschal None Eupen
## Eierschal None Eupen
## Freitag None Eupen
## Girf OÜ Laki Tallinn
## Großmann None Eupen
## PAC Systems PGmbH Hütte Eupen
## Rumma & Ko OÜ Tartu mnt. Tallinn
## Saffre None Tallinn
## """)

        
        s2 = ''
        for row in q:
            s2 += unicode(row.name) + " "
            if row.street is not None:
                s2 += unicode(row.street) + " "
            s2 += unicode(row.city.name) + "\n"

        #print s2
        
        self.assertEquivalent(s2,u"""\
Andreas Arens Eupen
Anton Ausdemwald Aachen
Emil Eierschal Eupen
Erna Eierschal Eupen
Frédéric Freitag Eupen
Gerd Großmann Eupen
Hans Flott Bierstraße München
Henri Bodard Verviers
Kati Kask Tallinn
Kurtz & Büntig Bergstraße Eupen
Mets & puu OÜ Tartu mnt. Tallinn
Reisebüro Freitag Hütte Eupen
Tõnu Tamm Tallinn        
""")

        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:
        
        db.shutdown()
Пример #6
0
    def test01(self):
        db = startup()
        s1 = ''
        q = db.query(Contact,\
                     "name street city.name",
                     orderBy="name")
        q.addColFilter('city',NotEmpty)
##         for row in q:
##             #print row[0]
##             s1 += str(row[0]) + " "
##             s1 += str(row[1]) + " "
##             s1 += str(row[2]) + "\n"
##         #print s1
##         self.assertEqual(s1,"""\
## Arens None Eupen
## Ausdemwald None Aachen
## Bodard None Verviers
## Eesti Telefon Sõpruse pst. Tallinn
## Eierschal None Eupen
## Eierschal None Eupen
## Freitag None Eupen
## Girf OÜ Laki Tallinn
## Großmann None Eupen
## PAC Systems PGmbH Hütte Eupen
## Rumma & Ko OÜ Tartu mnt. Tallinn
## Saffre None Tallinn
## """)

        
        s2 = ''
        for row in q:
            s2 += unicode(row.name) + " "
            if row.street is not None:
                s2 += unicode(row.street) + " "
            s2 += unicode(row.city.name) + "\n"

        #print s2
        
        self.assertEquivalent(s2,u"""\
Andreas Arens Eupen
Anton Ausdemwald Aachen
Emil Eierschal Eupen
Erna Eierschal Eupen
Frédéric Freitag Eupen
Gerd Großmann Eupen
Hans Flott Bierstraße München
Henri Bodard Verviers
Kati Kask Tallinn
Kurtz & Büntig Bergstraße Eupen
Mets & puu OÜ Tartu mnt. Tallinn
Reisebüro Freitag Hütte Eupen
Tõnu Tamm Tallinn        
""")

        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:
        
        db.shutdown()
Пример #7
0
    def test01(self):
        sess = startup()
        sess.startDump()

        # method 1 needs
        qry = sess.query(City)
        home = qry.findone(name="Eupen")

        sql = sess.peekDump()
        #print sql
        self.assertEquivalent(
            sql, """\
        SELECT nation_id, id, name, zipCode, inhabitants
        FROM Cities
        WHERE name = 'Eupen';
        """)

        self.assertEqual(home.nation.name, "Belgium")
        sql = sess.peekDump()
        self.assertEquivalent(
            sql, """\
        SELECT id, name_en, area, population, curr, isocode
        FROM Nations
        WHERE id = 'be';
        """)

        qry = sess.query(City, "id name nation.name")
        home = qry.findone(name="Eupen")
        sql = sess.peekDump()
        #print sql
        self.assertEquivalent(
            sql, """
        SELECT lead.nation_id, lead.id, lead.name,
               nation.id, nation.name_en
        FROM Cities AS lead
          LEFT JOIN Nations AS nation ON (lead.nation_id = nation.id)
        WHERE name = 'Eupen';
        """)

        self.assertEqual(home.nation.name, "Belgium")
        sql = sess.peekDump()
        self.assertEquivalent(sql, "")

        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:

        sess.shutdown()
Пример #8
0
    def test01(self):
        sess = startup()
        sess.startDump()

        # method 1 needs
        qry=sess.query(City)
        home=qry.findone(name="Eupen")
        
        sql=sess.peekDump()
        #print sql
        self.assertEquivalent(sql,"""\
        SELECT nation_id, id, name, zipCode, inhabitants
        FROM Cities
        WHERE name = 'Eupen';
        """)
        
        self.assertEqual(home.nation.name,"Belgium")
        sql=sess.peekDump()
        self.assertEquivalent(sql,"""\
        SELECT id, name_en, area, population, curr, isocode
        FROM Nations
        WHERE id = 'be';
        """)
        
        qry=sess.query(City,"id name nation.name")
        home=qry.findone(name="Eupen")
        sql=sess.peekDump()
        #print sql
        self.assertEquivalent(sql,"""
        SELECT lead.nation_id, lead.id, lead.name,
               nation.id, nation.name_en
        FROM Cities AS lead
          LEFT JOIN Nations AS nation ON (lead.nation_id = nation.id)
        WHERE name = 'Eupen';
        """)
        
        self.assertEqual(home.nation.name,"Belgium")
        sql=sess.peekDump()
        self.assertEquivalent(sql,"")
        
        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:
        
        sess.shutdown()
Пример #9
0
    def test02(self):
        from lino.apps.pinboard.pinboard_demo import startup
        self.doit(startup(), """\
Estonia is used by 10 rows in Cities
Belgium is used by 9 rows in Cities
Germany is used by 7 rows in Cities
English is used by 7 rows in Quotes
German is used by 1 rows in Quotes
French is used by 1 rows in Quotes
Project 1 is used by 3 rows in Projects
Project 1.3 is used by 2 rows in Projects
Project 1.3.2 is used by 2 rows in Projects
Georges Brassens is used by 1 rows in Quotes
Anonymus is used by 4 rows in Quotes
Peter Lauster is used by 1 rows in Quotes
Henry Louis Mencken is used by 2 rows in Quotes
Winston Churchill is used by 1 rows in Quotes        
        """)
Пример #10
0
    def test02(self):
        from lino.apps.pinboard.pinboard_demo import startup
        self.doit(
            startup(), """\
Estonia is used by 10 rows in Cities
Belgium is used by 9 rows in Cities
Germany is used by 7 rows in Cities
English is used by 7 rows in Quotes
German is used by 1 rows in Quotes
French is used by 1 rows in Quotes
Project 1 is used by 3 rows in Projects
Project 1.3 is used by 2 rows in Projects
Project 1.3.2 is used by 2 rows in Projects
Georges Brassens is used by 1 rows in Quotes
Anonymus is used by 4 rows in Quotes
Peter Lauster is used by 1 rows in Quotes
Henry Louis Mencken is used by 2 rows in Quotes
Winston Churchill is used by 1 rows in Quotes        
        """)
Пример #11
0
    def test01(self):
        "Accessing data that has not been inserted using adamo"
        sess = startup(populate=False)

        assert len(sess.query(Contact)) == 0, \
               "db not empty: previous test run didn't shutdown"

        db = sess.db
        #connection = center._center._connections[0]
        connection = db._connections[0]

        connection.sql_exec("""
        INSERT INTO Contacts (id,name)
               VALUES (1, "Luc");
        """)

        connection.sql_exec("""
        INSERT INTO Contacts (id,name)
               VALUES (2, "Ly");
        """)

        CONTACTS = sess.query(Contact)

        luc = CONTACTS.peek(1)
        self.assertEqual(luc.id, 1)
        self.assertEqual(luc.name, "Luc")
        ly = CONTACTS.peek(2)
        self.assertEqual(ly.id, 2)
        self.assertEqual(ly.name, "Ly")

        self.failIf(luc.isDirty())
        self.failIf(ly.isDirty())

        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:

        sess.shutdown()
Пример #12
0
    def test01(self):
        "Accessing data that has not been inserted using adamo"
        sess = startup(populate=False)
        
        assert len(sess.query(Contact)) == 0, \
               "db not empty: previous test run didn't shutdown"
        
        db = sess.db
        #connection = center._center._connections[0]
        connection = db._connections[0]
        
        connection.sql_exec("""
        INSERT INTO Contacts (id,name)
               VALUES (1, "Luc");
        """)

        connection.sql_exec("""
        INSERT INTO Contacts (id,name)
               VALUES (2, "Ly");
        """)

        CONTACTS = sess.query(Contact)

        luc = CONTACTS.peek(1)
        self.assertEqual(luc.id,1)
        self.assertEqual(luc.name,"Luc")
        ly = CONTACTS.peek(2)
        self.assertEqual(ly.id,2)
        self.assertEqual(ly.name,"Ly")

        self.failIf(luc.isDirty())
        self.failIf(ly.isDirty())
        
        # some other cases (for example 80.py) would fail if run
        # together with this case in one suite and if the following
        # lines were not:
        
        sess.shutdown()
Пример #13
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(langs="de en fr",big=True)
Пример #14
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(big=True)
Пример #15
0
 def setUp(self):
     TestCase.setUp(self)
     self.sess = startup(langs="en de", big=True)
Пример #16
0
# list of Belgian cities and number of inhabitants
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import Nation

sess=startup()
be=sess.query(Nation).peek("be")
qry=be.cities("name inhabitants",orderBy="inhabitants")

qry.show(width=50)

print
print qry.getSqlSelect()

sess.shutdown()
Пример #17
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(big=True)
Пример #18
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup()
Пример #19
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(langs='en de fr',big=True)
Пример #20
0
 def setUp(self):
     TestCase.setUp(self)
     
     self.sess = startup()
Пример #21
0
#from lino.apps.pinboard.pinboard_demo import startup
#from lino.apps.pinboard.pinboard_tables import QuotesReport
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import ContactsReport
from lino.forms.dbforms import ReportGridForm

dbc = startup()
#rpt=QuotesReport(dbc)
rpt = ContactsReport(dbc)
ReportGridForm(rpt).main()

# del dbc, qry

dbc.shutdown()
Пример #22
0
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import Nation
from lino.adamo.filters import NotEmpty

dbc = startup() # big=True)
        
qry=dbc.query(Nation,"id name cities")
qry.addColFilter('cities',NotEmpty)
qry.show(columnWidths="2 15 20")

print
print qry.getSqlSelect()

del dbc, qry
Пример #23
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(langs='en de fr', big=True)
Пример #24
0
 def test01(self):
     dbc=startup()
     NATIONS = dbc.query(Nation)
     be=NATIONS.parse("be")
     self.assertEqual(be.name,"Belgium")
     dbc.shutdown()
Пример #25
0
 def test01(self):
     dbc = startup()
     NATIONS = dbc.query(Nation)
     be = NATIONS.parse("be")
     self.assertEqual(be.name, "Belgium")
     dbc.shutdown()
Пример #26
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup(langs="de en fr", big=True)
Пример #27
0
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import Nation
from lino.adamo.filters import NotEmpty

dbc = startup() # big=True)
        
qry=dbc.query(Nation,"id name cities")
qry.addColFilter('cities',NotEmpty)
qry.show(columnWidths="2 15 20")

print
print qry.getSqlSelect()

del dbc, qry
Пример #28
0
 def setUp(self):
     TestCase.setUp(self)
     self.sess = startup(langs="en de", big=True)
Пример #29
0
 def setUp(self):
     TestCase.setUp(self)
     self.db = startup()
Пример #30
0
# from lino.apps.pinboard.pinboard_demo import startup
# from lino.apps.pinboard.pinboard_tables import QuotesReport
# from lino.config import tempdirfilename
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import ContactsReport
from lino.forms.dbforms import ReportRowForm

# dbc=startup(filename=tempdirfilename("tmp.db"))
dbc = startup()


class MyContactsReport(ContactsReport):
    columnSpec = """
    name
    org 
    person function
    phone gsm fax
    email website
    street house box
    nation city zip
    id lang
    """


# rpt=QuotesReport(dbc)
# rpt=PartnersReport(dbc)
rpt = MyContactsReport(dbc)

ReportRowForm(rpt, enabled=False).main()

# del rpt,dbc
Пример #31
0
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import Nation
from lino.adamo.filters import NotEmpty

dbc = startup(big=True)
        
qry=dbc.query(Nation,"id name")
qry.addColumn("cities",search="dre",orderBy="name",depth=1)
qry.addColFilter('cities',NotEmpty)
qry.show(
    columnWidths="2 15 *",
    title="Nations and their Cities containing search string 'dre'")

print
print qry.getSqlSelect()

del dbc, qry
Пример #32
0
# list of all cities and number of inhabitants
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import City
from lino.adamo.filters import NotEmpty

sess = startup()
qry = sess.query(City, "nation name inhabitants", orderBy="inhabitants")
qry.getColumnByName("inhabitants").addFilter(NotEmpty)
qry.show(width=50)

print
print qry.getSqlSelect()

sess.shutdown()
Пример #33
0
from lino.apps.contacts.contacts_demo import startup
from lino.apps.contacts.contacts_tables import Nation
from lino.adamo.filters import NotEmpty

dbc = startup(big=True)
        
qry=dbc.query(Nation,"id name")
qry.addColumn("cities",search="dre",orderBy="name",depth=1)
qry.addColFilter('cities',NotEmpty)
qry.show(
    columnWidths="2 15 *",
    title="Nations and their Cities containing search string 'dre'")

print
print qry.getSqlSelect()

del dbc, qry