コード例 #1
0
    def test_get_restrictions_raises_on_import_error(self, mock_import_module):
        # type: (MagicMock) -> None
        # Arrange
        mock_import_module.side_effect = ImportError

        user = '******'
        object_type = 'obj'
        operation = 'op'

        # Act
        with self.assertRaises(ImportError):
            restrictions.get_restrictions(user, object_type, operation)
コード例 #2
0
    def test_get_restrictions(self, mock_import_module):
        # type: (MagicMock) -> None
        # Arrange
        mock_import_module.return_value = auth_module = MagicMock()

        user = '******'
        object_type = 'obj'
        operation = 'op'

        # Act
        restrictions.get_restrictions(user, object_type, operation)

        # Assert
        auth_module.mock_fun.assert_called_with(user, object_type, operation)
コード例 #3
0
    def test_get_restrictions_disabled(self):
        # Arrange
        # Act
        actual_result = restrictions.get_restrictions('', '', '')

        # Assert
        self.assertIsNone(actual_result)