def test_definition(mocker): from fossir.modules.events.agreements import util mocker.patch.object(util, 'get_agreement_definitions', return_value={'foobar': 'test'}) assert Agreement(type='foobar').definition == 'test' assert Agreement(type='barfoo').definition is None
def test_reject(reason, on_behalf, expected_state): ip = '127.0.0.1' agreement = Agreement() agreement.reject(from_ip=ip, reason=reason, on_behalf=on_behalf) assert agreement.state == expected_state assert agreement.signed_from_ip == ip assert agreement.reason == reason assert agreement.signed_dt == now_utc() agreement.definition.handle_rejected.assert_called_with(agreement)
def test_reset(): agreement = Agreement() agreement.reset() assert agreement.state == AgreementState.pending assert agreement.attachment is None assert agreement.attachment_filename is None assert agreement.data is None assert agreement.reason is None assert agreement.signed_dt is None assert agreement.signed_from_ip is None
def _create_agreement(state): agreement = Agreement(uuid=str(uuid4()), event=dummy_event, type='dummy', person_email=dummy_person.email, person_name=dummy_person.name, state=state, identifier=dummy_person.identifier) db.session.add(agreement) db.session.flush() return agreement
def test_locator(): id_ = 1337 event_id = 9000 agreement = Agreement(id=id_, event_id=event_id) assert agreement.locator == {'id': id_, 'confId': event_id}
def test_is_orphan_no_definition(monkeypatch): monkeypatch.setattr(Agreement, 'definition', property(lambda s: None)) agreement = Agreement() with pytest.raises(ServiceUnavailable): agreement.is_orphan()
def test_is_orphan(dummy_event): agreement = Agreement(event=dummy_event) agreement.is_orphan() agreement.definition.is_agreement_orphan(agreement.event, agreement)
def test_belongs_to(): agreement = Agreement(identifier='foo') assert agreement.belongs_to(MagicMock(identifier='foo')) assert not agreement.belongs_to(MagicMock(identifier='bar'))
def test_render(): agreement = Agreement() agreement.render(None) agreement.definition.render_form.assert_called_with(agreement, None)