def test_get(self, session):
        """Calling 'get' with just a single keyword should return the models in
        the cache."""

        browser = Browser(session)
        assert browser.get("Sample") == []

        samples = browser.last(NUM_MODELS, "Sample")

        assert browser.get("Sample") == samples
    def test_get_relation_with_list_of_models(self, session):
        """Calling 'get' with just a single keyword and a string return the
        models the list of models returned."""

        browser = Browser(session)
        assert browser.get("Sample", "sample_type") == []

        samples = browser.last(NUM_MODELS, "Sample")
        sample_types = browser.get(samples, "sample_type")

        assert sample_types
        for st in sample_types:
            assert st.__class__.__name__ == "SampleType"
def test_consistency_with_has_many(session, method):

    browser = Browser(session)
    samples = browser.last(NUM_MODELS, "Sample")

    sample_types = getattr(browser, method)(samples, "sample_type")
    new_samples = getattr(browser, method)(sample_types[:1], "samples")

    # test at least one sample is in the model
    passes = False
    for s in new_samples:
        errs = check_model_in_cache(s, browser.model_cache)
        if not errs:
            passes = True
    assert passes, "At least one of the recalled samples should be in the model cache"