Example #1
0
def test_retrieve_has_many_through(session):
    browser = Browser(session)

    # we check to make sure that 'operations' are instances of Operations
    jobs = session.Job.last(50)
    operations = browser._retrieve_has_many_through(jobs, "operations")
    assert len(operations) > 0
    for model in jobs:
        assert "operations" in model._get_deserialized_data()
        other_models = model._get_deserialized_data()["operations"]
        if other_models is not None:
            for other_model in other_models:
                assert isinstance(other_model, pydent_models.Operation)
Example #2
0
def test_retrieve_with_many_through_for_jobs_and_operations(session):
    browser = Browser(session)
    jobs = session.Job.last(50)

    for j in jobs:
        assert not j._get_deserialized_data().get("operations", None)

    operations = browser._retrieve_has_many_through(jobs, "operations")
    assert len(operations) > 0
    assert not all(
        [m._get_deserialized_data()["operations"] is None for m in jobs])

    for model in jobs:
        assert "operations" in model._get_deserialized_data()
        other_models = model._get_deserialized_data()["operations"]
        if other_models is not None:
            for other_model in other_models:
                assert isinstance(other_model, pydent_models.Operation)