Beispiel #1
0
    def test_zfs_join_flags_bad_optflags(self):
        """ zfs._join_flags raises ValueError if invalid optflag paramter """
        with self.assertRaises(ValueError):
            zfs._join_flags(None, {'a': 1})

        with self.assertRaises(ValueError):
            zfs._join_flags(23, {'a': 1})
Beispiel #2
0
    def test_zfs_join_flags_count_optflag(self):
        """ zfs._join_flags has correct number of optflags in output """
        oflag = '-o'
        params = {'a': 1}
        result = zfs._join_flags(oflag, params)
        self.assertEqual(result.count(oflag), len(params))

        params = {}
        result = zfs._join_flags(oflag, params)
        self.assertEqual(result.count(oflag), len(params))
Beispiel #3
0
    def test_zfs_join_flags_bad_params(self):
        """ zfs._join_flags raises ValueError if invalid params """
        with self.assertRaises(ValueError):
            zfs._join_flags('-o', None)

        with self.assertRaises(ValueError):
            zfs._join_flags('-p', [1, 2, 3])

        with self.assertRaises(ValueError):
            zfs._join_flags('-p', 'foobar')
Beispiel #4
0
 def test_zfs_join_flags_converts_booleans(self):
     """ zfs._join_flags converts True -> on, False -> off """
     params = {'setfoo': False, 'setwark': True}
     result = zfs._join_flags('-o', params)
     self.assertEqual(sorted(["-o", "setfoo=off", "-o", "setwark=on"]),
                      sorted(result))
Beispiel #5
0
 def test_zfs_join_flags_in_key_equal_value(self):
     """ zfs._join_flags converts dict to key=value """
     oflag = '-o'
     params = {'a': 1}
     result = zfs._join_flags(oflag, params)
     self.assertEqual([oflag, "a=1"], result)
Beispiel #6
0
 def test_zfs_join_flags_empty_params_ok(self):
     """ zfs._join_flags returns empty list with empty params """
     self.assertEqual([], zfs._join_flags('-o', {}))