def test_tostring(self):
     slip = datatypes.Datatype('Slip', {'id': '1234'})
     date = datatypes.Datatype('Date', {'year': '2012'})
     self.assertEqual(
         commands.ModifyOnCondition('Slip', slip, date).tostring(),
         (b'<ModifyOnCondition condition="if-not-updated" type="Slip">'
          b'<Slip><id>1234</id></Slip><Date><year>2012</year></Date>'
          b'</ModifyOnCondition>'))
Example #2
0
 def test_invalid_user_email(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'password': '******'
     })
     with self.assertRaises(Exception):
         commands.CreateAccount(company, user).create()
Example #3
0
 def test_invalid_user_password(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'email': '*****@*****.**'
     })
     with self.assertRaises(Exception):
         commands.CreateUser(company, user).create()
Example #4
0
 def test_create(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'password': '******',
         'email': '*****@*****.**'
     })
     self.assertIsInstance(
         commands.CreateUser(company, user).create(), ET.Element)
Example #5
0
 def test_str(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'password': '******',
         'email': '*****@*****.**'
     })
     self.assertEqual(str(commands.CreateUser(company, user)),
                      '<CreateUser nickname=admin>')
Example #6
0
 def test_invalid_method(self):
     booking = datatypes.Datatype(
         'Booking',
         {'id': '476'}
     )
     approval = datatypes.Datatype(
         'Approval',
         {}
     )
     with self.assertRaises(Exception):
         commands.Submit('Booking', booking, approval).submit()
Example #7
0
 def test_submit(self):
     timesheet = datatypes.Datatype(
         'Timesheet',
         {'id': '476'}
     )
     approval = datatypes.Datatype(
         'Approval',
         {}
     )
     self.assertIsInstance(
         commands.Submit('Timesheet', timesheet, approval).submit(),
         ET.Element
     )
Example #8
0
 def test_tostring(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'password': '******',
         'email': '*****@*****.**'
     })
     self.assertEqual(
         commands.CreateUser(company, user).tostring(),
         (b'<CreateUser><Company><nickname>Acme Inc</nickname></Company>'
          b'<User><nickname>admin</nickname><password>p@ssw0rd</password>'
          b'<addr><Address><email>[email protected]</email></Address></addr>'
          b'</User></CreateUser>'))
Example #9
0
 def test_str(self):
     timesheet = datatypes.Datatype(
         'Timesheet',
         {'id': '476'}
     )
     approval = datatypes.Datatype(
         'Approval',
         {}
     )
     self.assertEqual(
         str(commands.Submit('Timesheet', timesheet, approval)),
         '<Submit type=Timesheet>'
     )
 def test_prettify(self):
     slip = datatypes.Datatype('Slip', {'id': '1234'})
     date = datatypes.Datatype('Date', {'year': '2012'})
     self.assertEqual(
         commands.ModifyOnCondition('Slip', slip, date).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<ModifyOnCondition condition="if-not-updated" type="Slip">\n'
          b'  <Slip>\n'
          b'    <id>1234</id>\n'
          b'  </Slip>\n'
          b'  <Date>\n'
          b'    <year>2012</year>\n'
          b'  </Date>\n'
          b'</ModifyOnCondition>\n'))
Example #11
0
 def test_tostring(self):
     timesheet = datatypes.Datatype(
         'Timesheet',
         {'id': '476'}
     )
     approval = datatypes.Datatype(
         'Approval',
         {}
     )
     self.assertEqual(
         commands.Submit('Timesheet', timesheet, approval).tostring(),
         (
             b'<Submit type="Timesheet"><Timesheet><id>476</id>'
             b'</Timesheet><Approval /></Submit>'
         )
     )
Example #12
0
 def test_tostring(self):
     slip = datatypes.Datatype('Slip', {'id': '1234'})
     self.assertEqual(
         commands.Modify('Slip', {
             'enable_custom': '1'
         }, slip).tostring(),
         b'<Modify enable_custom="1" type="Slip"><Slip><id>1234</id></Slip></Modify>'
     )
Example #13
0
 def test_prettify(self):
     self.assertEqual(
         datatypes.Datatype('Date', {
             'month': '03'
         }).prettify(), (b'<?xml version="1.0" encoding="utf-8"?>\n'
                         b'<Date>\n'
                         b'  <month>03</month>\n'
                         b'</Date>\n'))
Example #14
0
 def test_tostring_enable_custom(self):
     project = datatypes.Datatype('Project', {'name': 'New project'})
     self.assertEqual(
         commands.Add('Project', {
             'enable_custom': '1'
         }, project).tostring(),
         (b'<Add enable_custom="1" type="Project"><Project><name>'
          b'New project</name></Project></Add>'))
Example #15
0
 def test_tostring_addr(self):
     contact = datatypes.Datatype('Contact', {
         'name': 'John Doe',
         'email': '*****@*****.**'
     })
     self.assertEqual(
         contact.tostring(),
         (b'<Contact><name>John Doe</name><addr><Address>'
          b'<email>[email protected]</email></Address></addr></Contact>'))
Example #16
0
 def test_tostring_arg(self):
     timesheet = datatypes.Datatype('Timesheet', {'id': '1245'})
     self.assertEqual(
         commands.MakeURL('1', 'grid-timesheet', 'ta', timesheet).tostring(),
         (
             b'<MakeURL><arg><Timesheet><id>1245</id></Timesheet></arg>'
             b'<uid>1</uid><page>grid-timesheet</page><app>ta</app></MakeURL>'
         )
     )
Example #17
0
 def test_tostring_filter_datatype(self):
     slip = datatypes.Datatype('Slip', {'customerid': '7'})
     filter1 = commands.Read.Filter(None, None, slip).getFilter()
     read = commands.Read('Slip', 'equal to', {'limit': '0, 1000'},
                          [filter1], None, None)
     self.assertEqual(
         read.tostring(),
         (b'<Read limit="0, 1000" method="equal to" type="Slip">'
          b'<Slip><customerid>7</customerid></Slip></Read>'))
Example #18
0
 def test_invalid_type(self):
     with self.assertRaises(Exception):
         invoice = datatypes.Datatype(
             'Invoice',
             {
                 'relatedid': '1286',
                 'email_report': '1'
             }
         )
         commands.Report('Invoice', invoice)
Example #19
0
 def test_prettify(self):
     user = datatypes.Datatype('User', {'id': '1234'})
     self.assertEqual(
         connections.Whoami(user).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<Whoami>\n'
          b'  <User>\n'
          b'    <id>1234</id>\n'
          b'  </User>\n'
          b'</Whoami>\n'))
Example #20
0
 def test_prettify(self):
     slip = datatypes.Datatype('Slip', {'id': '1234'})
     self.assertEqual(
         commands.Delete('Slip', slip).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<Delete type="Slip">\n'
          b'  <Slip>\n'
          b'    <id>1234</id>\n'
          b'  </Slip>\n'
          b'</Delete>\n'))
Example #21
0
 def test_prettify(self):
     project = datatypes.Datatype('Project', {'name': 'New project'})
     self.assertEqual(
         commands.Add('Project', {}, project).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<Add type="Project">\n'
          b'  <Project>\n'
          b'    <name>New project</name>\n'
          b'  </Project>\n'
          b'</Add>\n'))
Example #22
0
 def test_tostring_filter_field(self):
     date = datatypes.Datatype('Date', {'year': '2013'})
     filter1 = commands.Read.Filter('older-than', 'date', date).getFilter()
     read = commands.Read('Slip', 'equal to', {'limit': '0, 1000'},
                          [filter1], None, None)
     self.assertEqual(
         read.tostring(),
         (b'<Read field="date" filter="older-than" limit="0, 1000" '
          b'method="equal to" type="Slip"><Date><year>2013</year>'
          b'</Date></Read>'))
Example #23
0
 def test_report(self):
     report = datatypes.Datatype(
         'Timesheet',
         {
             'relatedid': '1286',
             'email_report': '1'
         }
     )
     self.assertIsInstance(
         commands.Report('Timesheet', report).getReport(),
         ET.Element
     )
Example #24
0
 def test_str(self):
     report = datatypes.Datatype(
         'Timesheet',
         {
             'relatedid': '1286',
             'email_report': '1'
         }
     )
     self.assertEqual(
         str(commands.Report('Timesheet', report)),
         '<Report type=Timesheet>'
     )
Example #25
0
 def test_prettify(self):
     timesheet = datatypes.Datatype(
         'Timesheet',
         {'id': '476'}
     )
     approval = datatypes.Datatype(
         'Approval',
         {}
     )
     self.assertEqual(
         commands.Submit('Timesheet', timesheet, approval).prettify(),
         (
             b'<?xml version="1.0" encoding="utf-8"?>\n'
             b'<Submit type="Timesheet">\n'
             b'  <Timesheet>\n'
             b'    <id>476</id>\n'
             b'  </Timesheet>\n'
             b'  <Approval/>\n'
             b'</Submit>\n'
         )
     )
Example #26
0
 def test_prettify(self):
     flag = datatypes.Datatype('Flag', {'setting': '1'})
     self.assertEqual(
         commands.Switch('User', flag).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<User>\n'
          b'  <flags>\n'
          b'    <Flag>\n'
          b'      <setting>1</setting>\n'
          b'    </Flag>\n'
          b'  </flags>\n'
          b'</User>\n'))
Example #27
0
 def test_tostring(self):
     report = datatypes.Datatype(
         'Timesheet',
         {
             'relatedid': '1286',
             'email_report': '1'
         }
     )
     self.assertEqual(
         commands.Report('Timesheet', report).tostring(),
         (
             b'<Report type="Timesheet"><Timesheet><relatedid>1286</relatedid>'
             b'<email_report>1</email_report></Timesheet></Report>'
         )
     )
Example #28
0
 def test_prettify(self):
     company = datatypes.Datatype('Company', {'nickname': 'Acme Inc'})
     user = datatypes.Datatype('User', {
         'nickname': 'admin',
         'password': '******',
         'email': '*****@*****.**'
     })
     self.assertEqual(
         commands.CreateUser(company, user).prettify(),
         (b'<?xml version="1.0" encoding="utf-8"?>\n'
          b'<CreateUser>\n'
          b'  <Company>\n'
          b'    <nickname>Acme Inc</nickname>\n'
          b'  </Company>\n'
          b'  <User>\n'
          b'    <nickname>admin</nickname>\n'
          b'    <password>p@ssw0rd</password>\n'
          b'    <addr>\n'
          b'      <Address>\n'
          b'        <email>[email protected]</email>\n'
          b'      </Address>\n'
          b'    </addr>\n'
          b'  </User>\n'
          b'</CreateUser>\n'))
Example #29
0
 def test_prettify(self):
     timesheet = datatypes.Datatype('Timesheet', {'id': '1245'})
     self.assertEqual(
         commands.MakeURL('1', 'grid-timesheet', 'ta', timesheet).prettify(),
         (
             b'<?xml version="1.0" encoding="utf-8"?>\n'
             b'<MakeURL>\n'
             b'  <arg>\n'
             b'    <Timesheet>\n'
             b'      <id>1245</id>\n'
             b'    </Timesheet>\n'
             b'  </arg>\n'
             b'  <uid>1</uid>\n'
             b'  <page>grid-timesheet</page>\n'
             b'  <app>ta</app>\n'
             b'</MakeURL>\n'
         )
     )
Example #30
0
 def test_prettify(self):
     report = datatypes.Datatype(
         'Timesheet',
         {
             'relatedid': '1286',
             'email_report': '1'
         }
     )
     self.assertEqual(
         commands.Report('Timesheet', report).prettify(),
         b'<?xml version="1.0" encoding="utf-8"?>\n'
         b'<Report type="Timesheet">\n'
         b'  <Timesheet>\n'
         b'    <relatedid>1286</relatedid>\n'
         b'    <email_report>1</email_report>\n'
         b'  </Timesheet>\n'
         b'</Report>\n'
     )