Skip to content

Commit

Permalink
wip: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Aug 27, 2024
1 parent 6f79421 commit fbd1d55
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions osf_tests/metrics/reporters/test_institutional_users_reporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from __future__ import annotations
import dataclasses

import pytest

from osf import models as osfdb
from osf.metrics.reporters import InstitutionalUsersReporter
from osf_tests.factories import (
InstitutionFactory,
PreprintFactory,
ProjectFactory,
RegistrationFactory,
UserFactory,
)


@pytest.mark.django_db
class TestInstitutionalUsersReporter:
@pytest.fixture()
def institution(self):
return InstitutionFactory()

@pytest.fixture()
def affiliated_user_cases(self, institution) -> list[_UserCase]:
_cases = [
_UserCase(1, 1, 1, 1, 1, 1),
_UserCase(2, 2, 2, 2, 2, 2),
_UserCase(3, 3, 3, 3, 3, 3),
]
for _case in _cases:
_case.user.add_or_update_affiliated_institution(institution)
return _cases

@pytest.fixture()
def unaffiliated_user(self):
return UserFactory()

def _fill_user_case(self, usercase: _UserCase):
_included_projects = []
for _user in affiliated_users:
for _public in (True, False):
_proj = ProjectFactory(creator=_user, is_public=_public)
_proj.affiliated_institutions.add(institution)
_included_projects.append(_proj)
return _included_projects

def test_reporter(self, affiliated_user_cases, unaffiliated_user):
raise NotImplementedError('TODO')
_actual_reports = list(InstitutionalUsersReporter().report(_yearmonth))


@dataclasses.dataclass
class _UserCase:
public_project_count: int
private_project_count: int
public_registration_count: int
embargoed_registration_count: int
public_file_count: int
published_preprint_count: int
user: osfdb.OSFUser = dataclasses.field(default_factory=UserFactory)

0 comments on commit fbd1d55

Please sign in to comment.