'''
Test the grains module
'''
import integration


class TestModulesGrains(integration.ModuleCase):
    '''
    Test the grains module
    '''
    def test_items(self):
        '''
        grains.items
        '''
        opts = self.minion_opts
        self.assertEqual(
            self.run_function('grains.items')['test_grain'],
            opts['grains']['test_grain']
        )

    def test_item(self):
        '''
        grains.item
        '''
        opts = self.minion_opts
        self.assertEqual(
            self.run_function('grains.item', ['test_grain'])['test_grain'],
            opts['grains']['test_grain']
        )

    def test_ls(self):
        '''
        grains.ls
        '''
        check_for = (
            'cpuarch',
            'cpu_flags',
            'cpu_model',
            'domain',
            'fqdn',
            'host',
            'kernel',
            'kernelrelease',
            'localhost',
            'mem_total',
            'num_cpus',
            'os',
            'os_family',
            'path',
            'ps',
            'pythonpath',
            'pythonversion',
            'saltpath',
            'saltversion',
            'virtual',
        )
        lsgrains = self.run_function('grains.ls')
        for grain_name in check_for:
            self.assertTrue(grain_name in lsgrains)


if __name__ == '__main__':
    from integration import run_tests
    run_tests(TestModulesGrains)

@@ -1341,16 +1341,433 @@
 rains)%0A%0A
+    def test_set_val(self):%0A        '''%0A        test grains.set_val%0A        '''%0A        self.assertEqual(%0A                self.run_function(%0A                    'grains.setval',%0A                    %5B'setgrain', 'grainval'%5D),%0A                %7B'setgrain': 'grainval'%7D)%0A        self.assertTrue(%0A                self.run_function(%0A                    'grains.item', %5B'setgrain'%5D%0A                    )%0A                )%0A%0A%0A
 %0Aif __na

Add test to grains.setval