Пример #1
0
 def test_02_get_customers_by_name(self):
     cust = CustomerDto(customer_id=None,
                        first_name='Charlie',
                        last_name='Bone',
                        sex='M',
                        age=10,
                        birthday='2008-04-02',
                        email_address='*****@*****.**',
                        mail_shot_date='11/25',
                        iso_country_code='UK')
     cust_in_db = type(self).dao.create_customer(cust)
     self.assertEqual(cust.get_first_name(), cust_in_db.get_first_name())
Пример #2
0
 def test_11_update_customer_that_does_not_exist(self):
     cust = CustomerDto(customer_id=90,
                        first_name='Pangur',
                        last_name='Ban',
                        sex='M',
                        age=23,
                        birthday='1995-10-12',
                        email_address='*****@*****.**',
                        mail_shot_date='09/08',
                        iso_country_code='USA')
     type(self).dao.update_customer(cust)
     actual = type(self).dao.get_customer_by_id(90)
     self.assertEqual(None, actual)
Пример #3
0
 def test_01_get_customers(self):
     cust = CustomerDto(customer_id=None,
                        first_name='Spooky',
                        last_name='Dogg',
                        sex='M',
                        age=10,
                        birthday='2008-04-02',
                        email_address='*****@*****.**',
                        mail_shot_date='11/25',
                        iso_country_code='UK')
     cust_2 = CustomerDto(customer_id=None,
                          first_name='Charlie',
                          last_name='Bone',
                          sex='M',
                          age=10,
                          birthday='2008-04-02',
                          email_address='*****@*****.**',
                          mail_shot_date='11/25',
                          iso_country_code='UK')
     cust_1_in_db = type(self).dao.create_customer(cust)
     cust_2_in_bd = type(self).dao.create_customer(cust_2)
     actual = type(self).dao.get_customers()
     self.assertEqual([cust_1_in_db, cust_2_in_bd], actual)
Пример #4
0
 def test_04_create_customer(self):
     cust = CustomerDto(customer_id=None,
                        first_name='Pangur',
                        last_name='Ban',
                        sex='M',
                        age=23,
                        birthday='1995-10-12',
                        email_address='*****@*****.**',
                        mail_shot_date='09/08',
                        iso_country_code='USA')
     new_cust_in_db = type(self).dao.create_customer(cust)
     self.assertEqual(cust.get_first_name(),
                      new_cust_in_db.get_first_name())
     self.assertEqual(cust.get_last_name(), new_cust_in_db.get_last_name())
     self.assertEqual(cust.get_sex(), new_cust_in_db.get_sex())
     self.assertEqual(cust.get_age(), new_cust_in_db.get_age())
     self.assertEqual(cust.get_birthday(), new_cust_in_db.get_birthday())
     self.assertEqual(cust.get_email_addr(),
                      new_cust_in_db.get_email_addr())
     self.assertEqual(cust.get_mail_shot_date(),
                      new_cust_in_db.get_mail_shot_date())
     self.assertEqual(cust.get_iso_country_code(),
                      new_cust_in_db.get_iso_country_code())
Пример #5
0
 def test_09_update_customer(self):
     cust = CustomerDto(customer_id=None,
                        first_name='Pangur',
                        last_name='Ban',
                        sex='M',
                        age=23,
                        birthday='1995-10-12',
                        email_address='*****@*****.**',
                        mail_shot_date='09/08',
                        iso_country_code='USA')
     cust_in_db = type(self).dao.create_customer(cust)
     expected = CustomerDto(customer_id=cust_in_db.get_customer_id(),
                            first_name='Pangur',
                            last_name='Ban',
                            sex='M',
                            age=24,
                            birthday='1995-10-12',
                            email_address='*****@*****.**',
                            mail_shot_date='09/08',
                            iso_country_code='UK')
     type(self).dao.update_customer(expected)
     actual = type(self).dao.get_customer_by_id(
         cust_in_db.get_customer_id())
     self.assertEqual(expected, actual)
Пример #6
0
 def test_08_delete_customer(self):
     cust = CustomerDto(customer_id=None,
                        first_name='Pangur',
                        last_name='Ban',
                        sex='M',
                        age=23,
                        birthday='1995-10-12',
                        email_address='*****@*****.**',
                        mail_shot_date='09/08',
                        iso_country_code='USA')
     cust_in_db = type(self).dao.create_customer(cust)
     type(self).dao.delete_customer(cust_in_db)
     actual = type(self).dao.get_customer_by_id(
         cust_in_db.get_customer_id())
     self.assertEqual(None, actual)
Пример #7
0
    def test_12_ROLLBACK(self):
        cust = CustomerDto(customer_id=None,
                           first_name=None,
                           last_name='Bibi',
                           sex='F',
                           age=56,
                           birthday='1962-5-5',
                           email_address='*****@*****.**',
                           mail_shot_date='12/08',
                           iso_country_code='UK')

        with self.assertRaises(Exception) as e:
            type(self).dao.create_customer(cust)

        actual = type(self).dao.get_customers_by_name('Julia', 'Bibi')
        self.assertEqual([], actual)
Пример #8
0
    def test_00_test_create_dto_from_row(self):
        expected = CustomerDto(customer_id=None,
                               first_name='Spooky',
                               last_name='Dogg',
                               sex='M',
                               age=10,
                               birthday='2008-04-02',
                               email_address='*****@*****.**',
                               mail_shot_date='11/25',
                               iso_country_code='UK')

        row = [
            None, 'Spooky', 'Dogg', 'M', 10, '2008-04-02',
            '*****@*****.**', '11/25', 'UK'
        ]

        actual = CustomerPostgresDao._create_cust_dto_from_row(row)

        self.assertEqual(expected, actual)
Пример #9
0
def create_cust(c):
    return CustomerDto(c["customer_id"], c["first_name"], c["last_name"], c["sex"],
                       c["age"], c["birthday"], c["email_address"], c["mail_shot_date"],
                       c["iso_country_code"])
Пример #10
0
 def _create_cust_dto_from_row(row):
     return CustomerDto(customer_id=row[0], first_name=row[1], last_name=row[2], sex=row[3],
                        age=row[4], birthday=row[5], email_address=row[6], mail_shot_date=row[7],
                        iso_country_code=row[8])