@@ -872,28 +872,98 @@ def test_get_feature_evaluation_data(
872872 )
873873 url = f"{ base_url } ?environment_id={ environment .id } "
874874 mocked_get_feature_evaluation_data = mocker .patch (
875- "features.views.get_feature_evaluation_data" , autospec = True
875+ "features.views.get_feature_evaluation_data" ,
876+ autospec = True ,
876877 )
878+ today = date .today ()
877879 mocked_get_feature_evaluation_data .return_value = [
878- FeatureEvaluationData (count = 10 , day = date .today ()),
879- FeatureEvaluationData (count = 10 , day = date .today () - timedelta (days = 1 )),
880+ FeatureEvaluationData (count = 10 , day = today ),
881+ FeatureEvaluationData (
882+ count = 10 ,
883+ day = today ,
884+ labels = {"client_application_name" : "web" },
885+ ),
886+ FeatureEvaluationData (count = 10 , day = today - timedelta (days = 1 )),
880887 ]
881888 # When
882889 response = admin_client_new .get (url )
883890
884891 # Then
885892 assert response .status_code == status .HTTP_200_OK
886- assert len (response .json ()) == 2
887- assert response .json ()[0 ] == {"day" : str (date .today ()), "count" : 10 }
888- assert response .json ()[1 ] == {
889- "day" : str (date .today () - timedelta (days = 1 )),
890- "count" : 10 ,
891- }
893+ assert response .json () == [
894+ {
895+ "count" : 10 ,
896+ "day" : str (today ),
897+ "labels" : None ,
898+ },
899+ {
900+ "count" : 10 ,
901+ "day" : str (today ),
902+ "labels" : {
903+ "client_application_name" : "web" ,
904+ "client_application_version" : None ,
905+ },
906+ },
907+ {
908+ "count" : 10 ,
909+ "day" : str (today - timedelta (days = 1 )),
910+ "labels" : None ,
911+ },
912+ ]
892913 mocked_get_feature_evaluation_data .assert_called_with (
893914 feature = feature , period = 30 , environment_id = environment .id
894915 )
895916
896917
918+ def test_get_feature_evaluation_data__labels_filter__returns_expected (
919+ project : Project ,
920+ feature : Feature ,
921+ environment : Environment ,
922+ mocker : MockerFixture ,
923+ admin_client_new : APIClient ,
924+ ) -> None :
925+ # Given
926+ base_url = reverse (
927+ "api-v1:projects:project-features-get-evaluation-data" ,
928+ args = [project .id , feature .id ],
929+ )
930+ url = f"{ base_url } ?environment_id={ environment .id } &client_application_name=web"
931+ mocked_get_feature_evaluation_data = mocker .patch (
932+ "features.views.get_feature_evaluation_data" ,
933+ autospec = True ,
934+ )
935+ today = date .today ()
936+ mocked_get_feature_evaluation_data .return_value = [
937+ FeatureEvaluationData (
938+ count = 10 ,
939+ day = today ,
940+ labels = {"client_application_name" : "web" },
941+ ),
942+ ]
943+
944+ # When
945+ response = admin_client_new .get (url )
946+
947+ # Then
948+ assert response .status_code == status .HTTP_200_OK
949+ assert response .json () == [
950+ {
951+ "count" : 10 ,
952+ "day" : str (today ),
953+ "labels" : {
954+ "client_application_name" : "web" ,
955+ "client_application_version" : None ,
956+ },
957+ },
958+ ]
959+ mocked_get_feature_evaluation_data .assert_called_with (
960+ feature = feature ,
961+ period = 30 ,
962+ environment_id = environment .id ,
963+ labels_filter = {"client_application_name" : "web" },
964+ )
965+
966+
897967def test_create_segment_override_forbidden (
898968 feature : Feature ,
899969 segment : Segment ,
0 commit comments