Beispiel #1
0
    def test_handle_entities(self):
        """Call handle_entity on all matching Entity and VCSEntity pairs."""
        vcs_entities = {
            'match': VCSEntityFactory(),
            'no_db_match': VCSEntityFactory()
        }
        db_entities = {
            'match': EntityFactory(),
            'no_vcs_match': EntityFactory()
        }

        with patch('pontoon.sync.core.get_vcs_entities', return_value=vcs_entities), \
             patch('pontoon.sync.core.get_db_entities', return_value=db_entities), \
             patch('pontoon.sync.core.handle_entity') as mock_handle_entity:
            sync_project(self.db_project)

        mock_handle_entity.assert_has_calls([
            call(ANY, self.db_project, 'match', db_entities['match'],
                 vcs_entities['match']),
            call(ANY, self.db_project, 'no_vcs_match',
                 db_entities['no_vcs_match'], None),
            call(ANY, self.db_project, 'no_db_match', None,
                 vcs_entities['no_db_match']),
        ],
                                            any_order=True)
    def test_handle_project_handle_entities(self):
        """Call handle_entity on all matching Entity and VCSEntity pairs."""
        vcs_entities = {
            'match': VCSEntityFactory(),
            'no_db_match': VCSEntityFactory()
        }
        self.command.get_vcs_entities = Mock(return_value=vcs_entities)
        db_entities = {
            'match': EntityFactory(),
            'no_vcs_match': EntityFactory()
        }
        self.command.get_db_entities = Mock(return_value=db_entities)
        self.command.handle_entity = Mock()

        self.command.handle_project(self.db_project)
        self.command.handle_entity.assert_has_calls([
            call(ANY, self.db_project, 'match', db_entities['match'], vcs_entities['match']),
            call(ANY, self.db_project, 'no_vcs_match', db_entities['no_vcs_match'], None),
            call(ANY, self.db_project, 'no_db_match', None, vcs_entities['no_db_match']),
        ], any_order=True)