How to use sortinghat - 10 common examples

To help you get started, we’ve selected a few sortinghat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
def test_unique_enrollments(self):
        """Check if there is only one tuple with the same values"""

        with self.assertRaisesRegex(IntegrityError, DUP_CHECK_ERROR):
            uid = UniqueIdentity(uuid='John Smith')
            self.session.add(uid)

            org = Organization(name='Example')
            self.session.add(org)

            rol1 = Enrollment(uidentity=uid, organization=org)
            rol2 = Enrollment(uidentity=uid, organization=org)

            self.session.add(rol1)
            self.session.add(rol2)
            self.session.commit()
github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
def test_charset(self):
        """Check encoding charset"""

        # With an invalid encoding both names wouldn't be inserted;
        # In MySQL, chars 'ı' and 'i' are considered the same with a
        # collation distinct to _unicode_ci
        org1 = Organization(name='ıCompany'.encode('utf-8'))
        org2 = Organization(name='iCompany')

        self.session.add(org1)
        self.session.add(org2)
        self.session.commit()
github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
self.session.commit()

        self.session.rollback()

        with self.assertRaisesRegex(IntegrityError, NULL_CHECK_ERROR):
            uid = UniqueIdentity(uuid='John Smith')
            self.session.add(uid)

            rol2 = Enrollment(uidentity=uid)
            self.session.add(rol2)
            self.session.commit()

        self.session.rollback()

        with self.assertRaisesRegex(IntegrityError, NULL_CHECK_ERROR):
            org = Organization(name='Example')
            self.session.add(org)

            rol3 = Enrollment(organization=org)
            self.session.add(rol3)
            self.session.commit()

        self.session.rollback()
github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
def test_to_dict(self):
        """Test output of to_dict() method"""

        org = Organization(name='Example')
        self.session.add(org)

        dom = Domain(domain='example.com',
                     is_top_domain=True,
                     organization=org)
        self.session.add(dom)
        self.session.commit()

        # Tests
        d = dom.to_dict()

        self.assertIsInstance(d, dict)
        self.assertEqual(d['domain'], 'example.com')
        self.assertEqual(d['top_domain'], True)
        self.assertEqual(d['organization'], 'Example')
github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
def test_to_dict(self):
        """Test output of to_dict() method"""

        uid = UniqueIdentity(uuid='John Smith')
        self.session.add(uid)

        c = Country(code='US', name='United States of America', alpha3='USA')
        self.session.add(c)

        prf = Profile(uuid='John Smith', name='Smith, J.',
                      email='jsmith@example.com', is_bot=True,
                      country_code='US')

        self.session.add(prf)
        self.session.commit()

        # Tests
        d = prf.to_dict()

        self.assertIsInstance(d, dict)
        self.assertEqual(d['uuid'], 'John Smith')
        self.assertEqual(d['name'], 'Smith, J.')
        self.assertEqual(d['email'], 'jsmith@example.com')
github chaoss / grimoirelab-sortinghat / tests / test_model.py View on Github external
def test_unique_countries(self):
        """Check whether countries are unique"""

        with self.assertRaisesRegex(IntegrityError, DUP_CHECK_ERROR):
            c1 = Country(code='ES', name='Spain', alpha3='ESP')
            self.session.add(c1)

            c2 = Country(code='ES', name='España', alpha3='E')
            self.session.add(c2)

            self.session.commit()
github chaoss / grimoirelab-sortinghat / tests / test_api.py View on Github external
def test_equal_related_unique_identity(self):
        """Test that all remains the same when to_uuid is the unique identity related to 'from_id'"""

        # Add some unique identities and identities first
        api.add_unique_identity(self.db, 'John Smith')
        from_id = api.add_identity(self.db, 'scm', 'jsmith@example.com',
                                   uuid='John Smith')

        api.add_unique_identity(self.db, 'John Doe')
        api.add_identity(self.db, 'scm', 'jdoe@example.com',
                         uuid='John Doe')
        new_uuid = api.add_identity(self.db, 'scm', 'john.doe@example.com',
                                    uuid='John Doe')

        # Move the identity to the same unique identity
        api.move_identity(self.db, from_id, 'John Smith')

        # Nothing has happened
        with self.db.connect() as session:
            uidentities = session.query(UniqueIdentity).all()
            self.assertEqual(len(uidentities), 2)
github chaoss / grimoirelab-sortinghat / tests / test_cmd_unify.py View on Github external
def load_test_dataset(self):
        # Add some unique identities

        uuid = api.add_identity(self.db, source='scm', email='jsmith@example.com', name='John Smith')
        api.add_identity(self.db, source='scm', name='John Smith', uuid=uuid)
        api.add_identity(self.db, source='scm', username='jsmith', uuid=uuid)

        uuid = api.add_identity(self.db, source='alt', name='J. Smith', username='john_smith')
        api.add_identity(self.db, source='alt', name='John Smith', username='jsmith', uuid=uuid)
        api.add_identity(self.db, source='alt', email='jsmith', uuid=uuid)

        uuid = api.add_identity(self.db, source='scm', name='Jane Rae')
        api.add_identity(self.db, source='mls', email='jane.rae@example.net', name='Jane Rae Doe', uuid=uuid)

        uuid = api.add_identity(self.db, source='scm', name='J. Smith', username='john_smith')
        api.add_identity(self.db, source='scm', username='john_smith', uuid=uuid)
        api.add_identity(self.db, source='mls', username='Smith. J', uuid=uuid)
        api.add_identity(self.db, source='mls', email='JSmith@example.com', name='Smith. J', uuid=uuid)

        uuid = api.add_identity(self.db, source='mls', email='jrae@example.net', name='Jane Rae Doe')
        api.add_identity(self.db, source='mls', name='jrae', uuid=uuid)

        uuid = api.add_identity(self.db, source='scm', name='jrae')
github chaoss / grimoirelab-sortinghat / tests / test_api.py View on Github external
api.add_unique_identity(self.db, 'Smith J.')
        api.add_identity(self.db, 'mls', 'JSmith@example.com',
                         uuid='Smith J.')

        api.add_unique_identity(self.db, 'Jane Rae')
        api.add_identity(self.db, 'scm', 'janerae@example.com', 'Jane Rae', uuid='Jane Rae')

        api.add_unique_identity(self.db, 'JRae')
        api.add_identity(self.db, 'mls', name='Jane Rae', username='jrae', uuid='JRae')
        api.add_identity(self.db, 'scm', username='jrae', uuid='JRae')
        api.add_identity(self.db, 'scm', 'janerae@example.com', uuid='JRae')

        api.add_unique_identity(self.db, 'Jane')
        api.add_identity(self.db, 'unknown', 'jane@example.com', 'Jane', uuid='Jane')
        api.add_identity(self.db, 'unknown', 'jane@example.net', 'Jane', uuid='Jane')
        api.add_identity(self.db, 'unknown', 'jane@example.org', 'Jane', uuid='Jane')
        api.add_identity(self.db, 'unknown', 'jrae@example.org', 'Jane', uuid='Jane')
        api.add_identity(self.db, 'unknown', 'jrae@example.com', 'Jane', uuid='Jane')
        api.add_identity(self.db, 'unknown', 'janerae@example.com', 'Jane', uuid='Jane')

        # Tests
        get_uuids = lambda l: [u.uuid for u in l]

        matcher = create_identity_matcher('default')

        # John Smith
        m1 = api.match_identities(self.db, 'John Smith', matcher)
        uids = get_uuids(m1)

        self.assertListEqual(uids, ['Smith J.'])

        # Smith J.
github chaoss / grimoirelab-sortinghat / tests / test_cmd_affiliate.py View on Github external
api.add_domain(self.db, 'Bitergia', 'bitergia.com')
        api.add_domain(self.db, 'Bitergia', 'bitergia.org')

        api.add_organization(self.db, 'LibreSoft')

        # Add some unique identities
        jsmith_uuid = api.add_identity(self.db, 'scm', 'jsmith@us.example.com',
                                       'John Smith', 'jsmith')
        api.add_identity(self.db, 'scm', 'jsmith@example.net', 'John Smith',
                         uuid=jsmith_uuid)
        api.add_identity(self.db, 'scm', 'jsmith@bitergia.com', 'John Smith', 'jsmith',
                         uuid=jsmith_uuid)
        api.add_enrollment(self.db, jsmith_uuid, 'Bitergia')

        # Add John Doe identity
        api.add_identity(self.db, 'unknown', None, 'John Doe', 'jdoe')

        # Add Jane Rae identity
        jroe_uuid = api.add_identity(self.db, 'scm', 'jroe@example.com',
                                     'Jane Roe', 'jroe')
        api.add_identity(self.db, 'scm', 'jroe@example.com',
                         uuid=jroe_uuid)
        api.add_identity(self.db, 'unknown', 'jroe@bitergia.com',
                         uuid=jroe_uuid)

        # Add no valid email identity
        api.add_identity(self.db, 'test', 'novalidemail@')