def test_pub_has_no_dependents(pub_dep_mocks): pub = Publisher() has = pub.has_dependents() assert has is False # Check calls on this test case because it should hit all of them. for m in list(pub_dep_mocks.values()): m.return_value.exists.assert_called_once_with()
def test_update_cached_counts_none(f_mock): p = Publisher() p.update_cached_counts({}) assert p.brand_count == 0 assert p.indicia_publisher_count == 0 assert p.series_count == 0 assert p.issue_count == 0
def test_pub_has_no_dependents(pub_dep_mocks): pub = Publisher() has = pub.has_dependents() assert has is False # Check calls on this test case because it should hit all of them. for m in pub_dep_mocks.values(): m.return_value.exists.assert_called_once_with()
def test_update_cached_counts_subtract(f_mock): p = Publisher() p.update_cached_counts(DELTAS, negate=True) assert p.brand_count == BRAND_COUNT - DELTAS['brands'] assert p.indicia_publisher_count == (IPUB_COUNT - DELTAS['indicia publishers']) assert p.series_count == SERIES_COUNT - DELTAS['series'] assert p.issue_count == ISSUE_COUNT - DELTAS['issues']
def test_brand_use_active_issues(): with mock.patch('%s.BrandUse.emblem' % PATH) as em_mock: mock_qs = mock.MagicMock(query.QuerySet) em_mock.issue_set.exclude.return_value.filter.return_value = mock_qs bu = BrandUse(publisher=Publisher()) ai = bu.active_issues() assert ai is mock_qs em_mock.issue_set.exclude.assert_called_once_with(deleted=True) em_mock.issue_set.exclude.return_value.filter.assert_called_once_with( issue__series__publisher=bu.publisher)
def test_publisher_stat_counts(pub_child_set_mocks): counts = Publisher().stat_counts() assert counts == {'publishers': 1}
def test_pub_has_non_dependents_nonzero_counts(pub_dep_mocks, which_count): pub = Publisher(**{'%s_count' % which_count: 1}) has = pub.has_dependents() assert has is False
def test_pub_has_dependents_revs_exist(pub_dep_mocks, which_exists): pub_dep_mocks[which_exists].return_value.exists.return_value = True pub = Publisher() has = pub.has_dependents() assert has is True