Exemplo n.º 1
0
def test_employment_list_superuser(superadmin_client):
    EmploymentFactory.create_batch(2)
    EmploymentFactory.create(user=superadmin_client.user)

    url = reverse('employment-list')

    result = superadmin_client.get(url)
    assert result.status_code == status.HTTP_200_OK
    json = result.json()
    assert len(json['data']) == 3
Exemplo n.º 2
0
def test_employment_list_authenticated(auth_client):
    EmploymentFactory.create_batch(2)
    employment = EmploymentFactory.create(user=auth_client.user)

    url = reverse('employment-list')

    result = auth_client.get(url)
    assert result.status_code == status.HTTP_200_OK
    json = result.json()
    assert len(json['data']) == 1
    assert json['data'][0]['id'] == str(employment.id)
Exemplo n.º 3
0
    def setUp(self):
        """Set the environment for the tests up."""
        super().setUp()

        self.employments = [
            EmploymentFactory.create(user=self.user,
                                     start_date=datetime.date(2010, 1, 1),
                                     end_date=datetime.date(2015, 1, 1)),
            EmploymentFactory.create(user=self.user,
                                     start_date=datetime.date(2015, 1, 2))
        ]

        EmploymentFactory.create_batch(10)
Exemplo n.º 4
0
def test_employment_list_supervisor(auth_client):
    user = UserFactory.create()
    auth_client.user.supervisees.add(user)

    EmploymentFactory.create_batch(1)
    EmploymentFactory.create(user=auth_client.user)
    EmploymentFactory.create(user=user)

    url = reverse('employment-list')

    result = auth_client.get(url)
    assert result.status_code == status.HTTP_200_OK
    json = result.json()
    assert len(json['data']) == 2
def test_notify_changed_employments(db, mailoutbox, freezer):
    email = "*****@*****.**"

    # employments changed too far in the past
    freezer.move_to("2017-08-27")
    EmploymentFactory.create_batch(2)

    # employments which should show up in report
    freezer.move_to("2017-09-03")
    finished = EmploymentFactory.create(end_date=date(2017, 10, 10),
                                        percentage=80)
    new = EmploymentFactory.create(percentage=100)

    freezer.move_to("2017-09-04")
    call_command("notify_changed_employments", email=email)

    # checks
    assert len(mailoutbox) == 1
    mail = mailoutbox[0]
    assert mail.to == [email]
    print(mail.body)
    assert "80% {0}".format(finished.user.get_full_name()) in mail.body
    assert "None       100% {0}".format(new.user.get_full_name()) in mail.body