示例#1
0
def test_awesome_stuff(relation_detector):  # NOQA
    users = [User(name='Anders', age=12) for _ in range(1)]

    User.objects.insert(users)

    handin = Handin(score=1, users=users[0])
    handin.save()

    assert score() == 50
示例#2
0
def test_raising_exceptions_on_missing_subscriptions(relation_detector):  # NOQA
    users = [User(name='Anders', age=12) for _ in range(1)]

    inserted_users = User.objects.insert(users)

    handin = Handin(score=1, users=inserted_users)
    handin.save()

    with pytest.raises(RelationMissingError):
        with relation_detector(score_with_missing_relations):
            assert score_with_missing_relations() == 50
示例#3
0
def test_no_exceptions_raised_with_all_subscriptions(relation_detector):  # NOQA
    users = [User(name='Anders', age=12) for _ in range(1)]

    inserted_users = User.objects.insert(users)

    handin = Handin(score=1, users=inserted_users)
    handin.save()

    with relation_detector(score_with_sources):
        assert score_with_sources() == 50

    with relation_detector(score_with_relations):
        assert score_with_relations() == 50
示例#4
0
def score_with_relations():
    handin = Handin.objects().first()
    handin.users[0]
    return 50
示例#5
0
def score_with_sources():
    handin = Handin.objects().first()
    handin.users[0]
    return 50
示例#6
0
def test_data_source_for_entity():
    data_source = MongoDataSource(User)
    assert data_source.for_entity(User()) == True
    assert data_source.for_entity(Handin()) == False
示例#7
0
def score():
    handin = Handin.objects().first()
    handin.users[0]
    return 50