Example #1
0
    def test_getter_setter(self):
        """Test getters and setters for the Group GID values."""
        group_data = GroupData()
        group_data.name = "group"

        # everything should be unset by default
        assert group_data.gid == 0
        assert group_data.gid_mode == ID_MODE_USE_DEFAULT
        assert group_data.get_gid() is None

        group_data.set_gid(789)

        # now everything is set
        assert group_data.gid == 789
        assert group_data.gid_mode == ID_MODE_USE_VALUE
        assert group_data.get_gid() == 789

        group_data.gid_mode = ID_MODE_USE_DEFAULT

        # mode should decide whether numbers are used, regardless of being stored
        assert group_data.gid_mode == ID_MODE_USE_DEFAULT
        assert group_data.gid == 789
        assert group_data.get_gid() is None

        group_data.set_gid(None)

        # setting None resets everything
        assert group_data.gid == 0
        assert group_data.gid_mode == ID_MODE_USE_DEFAULT
        assert group_data.get_gid() is None
Example #2
0
    def getter_setter_test(self):
        """Test getters and setters for the Group GID values."""
        group_data = GroupData()
        group_data.name = "group"

        # everything should be unset by default
        self.assertEqual(group_data.gid, 0)
        self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT)
        self.assertEqual(group_data.get_gid(), None)

        group_data.set_gid(789)

        # now everything is set
        self.assertEqual(group_data.gid, 789)
        self.assertEqual(group_data.gid_mode, ID_MODE_USE_VALUE)
        self.assertEqual(group_data.get_gid(), 789)

        group_data.gid_mode = ID_MODE_USE_DEFAULT

        # mode should decide whether numbers are used, regardless of being stored
        self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT)
        self.assertEqual(group_data.gid, 789)
        self.assertEqual(group_data.get_gid(), None)

        group_data.set_gid(None)

        # setting None resets everything
        self.assertEqual(group_data.gid, 0)
        self.assertEqual(group_data.gid_mode, ID_MODE_USE_DEFAULT)
        self.assertEqual(group_data.get_gid(), None)