import unittest

from ..framework import cli_test_suite
from .util import DEFAULT_MANAGEMENT_KEY


@cli_test_suite
def additional_tests(ykman_cli):
    class Misc(unittest.TestCase):

        def setUp(self):
            ykman_cli('piv', 'reset', '-f')

        def test_info(self):
            output = ykman_cli('piv', 'info')
            self.assertIn('PIV version:', output)

        def test_reset(self):
            output = ykman_cli('piv', 'reset', '-f')
            self.assertIn('Success!', output)

        def test_write_read_object(self):
            ykman_cli(
                'piv', 'write-object',
                '-m', DEFAULT_MANAGEMENT_KEY, '0x5f0001',
                '-', input='test data')
            output = ykman_cli('piv', 'read-object', '0x5f0001')
            self.assertEqual('test data\n', output)

    return [Misc]

@@ -537,32 +537,101 @@
 d_object(self):%0A
+            data = 'test data'%0A            for i in range(0, 3):%0A    
             ykma
@@ -637,16 +637,20 @@
 an_cli(%0A
+    
         
@@ -696,16 +696,20 @@
         
+    
 '-m', DE
@@ -758,16 +758,20 @@
         
+    
 '-', inp
@@ -773,27 +773,20 @@
 , input=
-'test 
 data
-'
 )%0A      
@@ -783,38 +783,40 @@
 ta)%0A            
-output
+    data
  = ykman_cli('pi
@@ -875,16 +875,22 @@
 rtEqual(
+data, 
 'test da
@@ -895,19 +895,9 @@
 data
-%5Cn', output
+'
 )%0A%0A 

Test that repeated read/write-object cycles do not change the data