Example #1
0
    def test_match__street_address_line2_filled_different(self):
        m1 = UserAddress(user_id=1, street_address_line2='lorem ipsum sitam')
        m1.save()
        m2 = UserAddress(user_id=1, street_address_line2='lorem ipsum dolor')
        m2.save()

        self.assertNotEqual(m2.id, m1.id)
Example #2
0
    def test_match__state_is_null(self):
        m1 = UserAddress(user_id=1, state=None)
        m1.save()
        m2 = UserAddress(user_id=1, state='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #3
0
    def test_match__name_not_filled(self):
        m1 = UserAddress(user_id=1, name='')
        m1.save()
        m2 = UserAddress(user_id=1, name='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #4
0
    def test_match__zipcode_is_null(self):
        m1 = UserAddress(user_id=1, zipcode=None)
        m1.save()
        m2 = UserAddress(user_id=1, zipcode='WC2N 5DU UK')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #5
0
    def test_match__state_filled_center(self):
        m1 = UserAddress(user_id=1, state='ipsum')
        m1.save()
        m2 = UserAddress(user_id=1, state='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #6
0
    def test_match__name_filled_different(self):
        m1 = UserAddress(user_id=1, name='lorem ipsum sitam')
        m1.save()
        m2 = UserAddress(user_id=1, name='lorem ipsum dolor')
        m2.save()

        self.assertNotEqual(m2.id, m1.id)
Example #7
0
    def test_match__country_filled_different(self):
        m1 = UserAddress(user_id=1, country='US')
        m1.save()
        m2 = UserAddress(user_id=1, country='UK')
        m2.save()

        self.assertNotEqual(m2.id, m1.id)
Example #8
0
    def test_match__zipcode_not_filled(self):
        m1 = UserAddress(user_id=1, zipcode='')
        m1.save()
        m2 = UserAddress(user_id=1, zipcode='WC2N 5DU UK')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #9
0
    def test_match__country_filled_fully_duplicated(self):
        m1 = UserAddress(user_id=1, country='UK')
        m1.save()
        m2 = UserAddress(user_id=1, country='UK')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #10
0
    def test_match__state_filled_fully_duplicated(self):
        m1 = UserAddress(user_id=1, state='lorem ipsum dolor')
        m1.save()
        m2 = UserAddress(user_id=1, state='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #11
0
    def test_match__street_address_line2_not_filled(self):
        m1 = UserAddress(user_id=1, street_address_line2='')
        m1.save()
        m2 = UserAddress(user_id=1, street_address_line2='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #12
0
    def test_match__city_filled_right(self):
        m1 = UserAddress(user_id=1, city='dolor')
        m1.save()
        m2 = UserAddress(user_id=1, city='lorem ipsum dolor')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #13
0
    def test_match__zipcode_filled_different(self):
        m1 = UserAddress(user_id=1, zipcode='WC2N ABC')
        m1.save()
        m2 = UserAddress(user_id=1, zipcode='WC2N DEF')
        m2.save()

        self.assertNotEqual(m2.id, m1.id)
Example #14
0
    def test_match__zipcode_filled_fully_duplicated(self):
        m1 = UserAddress(user_id=1, zipcode='WC2N 5DU')
        m1.save()
        m2 = UserAddress(user_id=1, zipcode='WC2N 5DU')
        m2.save()

        self.assertEqual(m2.id, m1.id)
Example #15
0
 def test_full_address_3(self):
     m = UserAddress(user_id=1,
                     name='Max Mustermann',
                     street_address='456 Randomstreet',
                     city='Giventown')
     m.save()
     self.assertEqual(m.full_address,
                      '456 Randomstreet\nNone\nNone Giventown None ')
Example #16
0
    def test_match__zipcode_filled_right(self):
        m1 = UserAddress(user_id=1, zipcode='5DU')
        m1.save()
        m2 = UserAddress(user_id=1, zipcode='WC2N 5DU')
        m2.save()

        # must be different! thy are different zip codes
        self.assertNotEqual(m2.id, m1.id)
Example #17
0
 def test_full_address_4(self):
     m = UserAddress(user_id=1,
                     name='Max Mustermann',
                     street_address='789 Otherstreet',
                     city='Giventown',
                     country='NL')
     m.save()
     self.assertEqual(m.full_address,
                      '789 Otherstreet\nNone\nNone Giventown None NL')
Example #18
0
    def test_deduplication_raises_conflict_error_on_different_pk(self):
        m = UserAddress(id=1, user_id=1, name='Max', city='Giventown')
        m.save()
        m = UserAddress(id=2,
                        user_id=1,
                        name='Max Mustermann',
                        street_address='Randomstreet',
                        city='Giventown')
        with self.assertRaises(IntegrityError) as err_ctx:
            m.save()

        self.assertEqual(err_ctx.exception.args[0], 'address duplicated error')
Example #19
0
    def test_deduplication_leaves_just_2_unique_records(self):
        m = UserAddress(user_id=1, name='Max', city='Giventown')
        m.save()
        m = UserAddress(user_id=1,
                        name='Max Mustermann',
                        street_address='Randomstreet',
                        city='Giventown')
        m.save()
        m = UserAddress(user_id=1,
                        name='Max Mustermann',
                        street_address='456 Randomstreet',
                        city='Giventown')
        m.save()
        m = UserAddress(user_id=1,
                        name='Max Mustermann',
                        street_address='789 Otherstreet',
                        city='Giventown',
                        country='NL')
        m.save()
        total_count = UserAddress.objects.count()

        self.assertEqual(2, total_count)
Example #20
0
 def test_full_address_1(self):
     m = UserAddress(user_id=1, name='Max', city='Giventown')
     m.save()
     self.assertEqual(m.full_address, '\nNone\nNone Giventown None ')