@@ -715,6 +715,25 @@ def test_basic_group_identify(self):
715715 self .assertTrue (isinstance (msg ["timestamp" ], str ))
716716 self .assertIsNone (msg .get ("uuid" ))
717717
718+ def test_basic_group_identify_with_distinct_id (self ):
719+ success , msg = self .client .group_identify ("organization" , "id:5" , distinct_id = "distinct_id" )
720+ self .assertTrue (success )
721+ self .assertEqual (msg ["event" ], "$groupidentify" )
722+ self .assertEqual (msg ["distinct_id" ], "distinct_id" )
723+ self .assertEqual (
724+ msg ["properties" ],
725+ {
726+ "$group_type" : "organization" ,
727+ "$group_key" : "id:5" ,
728+ "$group_set" : {},
729+ "$lib" : "posthog-python" ,
730+ "$lib_version" : VERSION ,
731+ "$geoip_disable" : True ,
732+ },
733+ )
734+ self .assertTrue (isinstance (msg ["timestamp" ], str ))
735+ self .assertIsNone (msg .get ("uuid" ))
736+
718737 def test_advanced_group_identify (self ):
719738 success , msg = self .client .group_identify (
720739 "organization" , "id:5" , {"trait" : "value" }, {"ip" : "192.168.0.1" }, datetime (2014 , 9 , 3 ), "new-uuid"
@@ -737,6 +756,28 @@ def test_advanced_group_identify(self):
737756 self .assertEqual (msg ["timestamp" ], "2014-09-03T00:00:00+00:00" )
738757 self .assertEqual (msg ["context" ]["ip" ], "192.168.0.1" )
739758
759+ def test_advanced_group_identify_with_distinct_id (self ):
760+ success , msg = self .client .group_identify (
761+ "organization" , "id:5" , {"trait" : "value" }, {"ip" : "192.168.0.1" }, datetime (2014 , 9 , 3 ), "new-uuid" , distinct_id = "distinct_id"
762+ )
763+
764+ self .assertTrue (success )
765+ self .assertEqual (msg ["event" ], "$groupidentify" )
766+ self .assertEqual (msg ["distinct_id" ], "distinct_id" )
767+ self .assertEqual (
768+ msg ["properties" ],
769+ {
770+ "$group_type" : "organization" ,
771+ "$group_key" : "id:5" ,
772+ "$group_set" : {"trait" : "value" },
773+ "$lib" : "posthog-python" ,
774+ "$lib_version" : VERSION ,
775+ "$geoip_disable" : True ,
776+ },
777+ )
778+ self .assertEqual (msg ["timestamp" ], "2014-09-03T00:00:00+00:00" )
779+ self .assertEqual (msg ["context" ]["ip" ], "192.168.0.1" )
780+
740781 def test_basic_alias (self ):
741782 client = self .client
742783 success , msg = client .alias ("previousId" , "distinct_id" )
0 commit comments