def test_can_recommend(test_ctx, caplog): caplog.set_level(logging.INFO) # Create a new instance of a SimilarityRecommender. ctx = install_continuous_data(test_ctx) r = SimilarityRecommender(ctx) assert check_matrix_built(caplog) # Test that we can't recommend if we have not enough client info. assert not r.can_recommend({}) # Test that we can recommend for a normal client. assert r.can_recommend(generate_a_fake_taar_client()) # Check that we can not recommend if any required client field is missing. required_fields = CATEGORICAL_FEATURES + CONTINUOUS_FEATURES for required_field in required_fields: profile_without_x = generate_a_fake_taar_client() # Make an empty value in a required field in the client info dict. profile_without_x[required_field] = None assert not r.can_recommend(profile_without_x) # Completely remove (in place) the entire required field from the dict. del profile_without_x[required_field] assert not r.can_recommend(profile_without_x)
def test_soft_fail(test_ctx, caplog): # Create a new instance of a SimilarityRecommender. with mock_install_no_data(test_ctx): r = SimilarityRecommender(test_ctx) # Don't recommend if the source files cannot be found. assert not r.can_recommend({})
def test_soft_fail(test_ctx, caplog): # Create a new instance of a SimilarityRecommender. ctx = install_no_data(test_ctx) r = SimilarityRecommender(ctx) # Don't recommend if the source files cannot be found. assert not r.can_recommend({}) assert not check_matrix_built(caplog)
def test_soft_fail(): # Create a new instance of a SimilarityRecommender. ctx = Context() ctx['utils'] = MockNoDataUtils() ctx['clock'] = Clock() ctx['cache'] = JSONCache(ctx) r = SimilarityRecommender(ctx) # Don't recommend if the source files cannot be found. assert not r.can_recommend({})
def test_can_recommend(instantiate_mocked_s3_bucket): # Create a new instance of a SimilarityRecommender. r = SimilarityRecommender() # Test that we can't recommend if we have not enough client info. assert not r.can_recommend({}) # Test that we can recommend for a normal client. assert r.can_recommend(generate_a_fake_taar_client()) # Check that we can not recommend if any required client field is missing. required_fields = CATEGORICAL_FEATURES + CONTINUOUS_FEATURES for required_field in required_fields: profile_without_x = generate_a_fake_taar_client() # Make an empty value in a required field in the client info dict. profile_without_x[required_field] = None assert not r.can_recommend(profile_without_x) # Completely remove (in place) the entire required field from the dict. del profile_without_x[required_field] assert not r.can_recommend(profile_without_x)
def test_soft_fail(): # Create a new instance of a SimilarityRecommender. r = SimilarityRecommender() # Don't recommend if the source files cannot be found. assert not r.can_recommend({})