@@ -599,3 +599,114 @@ def test_share_config_no_path():
599
599
shares = list (ic .shares ())
600
600
assert len (shares ) == 1
601
601
assert shares [0 ].path () is None
602
+
603
+
604
+ @pytest .mark .parametrize (
605
+ "json_a,json_b,iname,expect_equal" ,
606
+ [
607
+ (config1 , config1 , "foobar" , True ),
608
+ (addc_config1 , addc_config1 , "demo" , True ),
609
+ (config1 , config2 , "foobar" , False ),
610
+ (
611
+ """{
612
+ "samba-container-config": "v0",
613
+ "configs": {
614
+ "foobar":{
615
+ "shares": ["flunk"],
616
+ "globals": ["global0"]
617
+ }
618
+ },
619
+ "shares": {
620
+ "flunk": {
621
+ "options": {"path": "/mnt/yikes"}
622
+ }
623
+ },
624
+ "globals": {
625
+ "global0": {
626
+ "options": {
627
+ "server min protocol": "SMB2"
628
+ }
629
+ }
630
+ }
631
+ }""" ,
632
+ """{
633
+ "samba-container-config": "v0",
634
+ "configs": {
635
+ "foobar":{
636
+ "shares": ["flunk"],
637
+ "globals": ["global0"]
638
+ }
639
+ },
640
+ "shares": {
641
+ "flunk": {
642
+ "options": {"path": "/mnt/psych"}
643
+ }
644
+ },
645
+ "globals": {
646
+ "global0": {
647
+ "options": {
648
+ "server min protocol": "SMB2"
649
+ }
650
+ }
651
+ }
652
+ }""" ,
653
+ "foobar" ,
654
+ False ,
655
+ ),
656
+ (
657
+ """{
658
+ "samba-container-config": "v0",
659
+ "configs": {
660
+ "foobar":{
661
+ "shares": ["flunk"],
662
+ "globals": ["global0"]
663
+ }
664
+ },
665
+ "shares": {
666
+ "flunk": {
667
+ "options": {"path": "/mnt/yikes"}
668
+ }
669
+ },
670
+ "globals": {
671
+ "global0": {
672
+ "options": {
673
+ "server min protocol": "SMB2"
674
+ }
675
+ }
676
+ }
677
+ }""" ,
678
+ """{
679
+ "samba-container-config": "v0",
680
+ "configs": {
681
+ "foobar":{
682
+ "shares": ["flunk"],
683
+ "globals": ["global0"]
684
+ }
685
+ },
686
+ "shares": {
687
+ "flunk": {
688
+ "options": {"path": "/mnt/yikes"}
689
+ }
690
+ },
691
+ "globals": {
692
+ "global0": {
693
+ "options": {
694
+ "server min protocol": "SMB1"
695
+ }
696
+ }
697
+ }
698
+ }""" ,
699
+ "foobar" ,
700
+ False ,
701
+ ),
702
+ ],
703
+ )
704
+ def test_instance_config_equality (json_a , json_b , iname , expect_equal ):
705
+ gca = sambacc .config .GlobalConfig (io .StringIO (json_a ))
706
+ gcb = sambacc .config .GlobalConfig (io .StringIO (json_b ))
707
+ instance_a = gca .get (iname )
708
+ instance_b = gcb .get (iname )
709
+ if expect_equal :
710
+ assert instance_a == instance_b
711
+ else :
712
+ assert instance_a != instance_b
0 commit comments