示例#1
0
def test_handle_dependents_to_singleton(year_began, key_date):
    with mock.patch('%s.save' % IREV) as save_mock, \
            mock.patch('%s.commit_to_display' % IREV) as commit_mock:
        # Make the IssueRevision that would be returned by the patched
        # constructor call.  Only patch the methods for this.
        s = Series()
        c = Changeset()
        ir_params = {
            'changeset': c,
            'series': s,
            'after': None,
            'number': '[nn]',
            'publication_date': year_began,
        }
        ir = IssueRevision(**ir_params)

        with mock.patch(IREV) as ir_class_mock:
            # Now patch the IssueRevision constructor itself.
            ir_class_mock.return_value = ir
            sr = SeriesRevision(changeset=c,
                                series=s,
                                is_singleton=True,
                                year_began=year_began)

            sr._handle_dependents({'to is_singleton': True})

            ir_class_mock.assert_called_once_with(**ir_params)
            assert ir.key_date == key_date
            save_mock.assert_called_once_with()
            assert not commit_mock.called
def test_handle_dependents_to_singleton(year_began, key_date):
    with mock.patch('%s.save' % IREV) as save_mock, \
            mock.patch('%s.commit_to_display' % IREV) as commit_mock:
        # Make the IssueRevision that would be returned by the patched
        # constructor call.  Only patch the methods for this.
        s = Series()
        c = Changeset()
        ir_params = {
            'changeset': c,
            'series': s,
            'after': None,
            'number': '[nn]',
            'publication_date': year_began,
        }
        ir = IssueRevision(**ir_params)

        with mock.patch(IREV) as ir_class_mock:
            # Now patch the IssueRevision constructor itself.
            ir_class_mock.return_value = ir
            sr = SeriesRevision(changeset=c, series=s, is_singleton=True,
                                year_began=year_began)

            sr._handle_dependents({'to is_singleton': True})

            ir_class_mock.assert_called_once_with(**ir_params)
            assert ir.key_date == key_date
            save_mock.assert_called_once_with()
            assert not commit_mock.called
示例#3
0
def test_handle_dependents_no_singleton():
    with mock.patch(IREV) as ir_class_mock:
        sr = SeriesRevision()
        sr._handle_dependents({'to is_singleton': False})
        assert ir_class_mock.called is False
def test_handle_dependents_no_singleton():
        with mock.patch(IREV) as ir_class_mock:
            sr = SeriesRevision()
            sr._handle_dependents({'to is_singleton': False})
            assert ir_class_mock.called is False