<s> from test import CollectorTestCase <EOL> from test import get_collector_config <EOL> from test import unittest <EOL> from mock import Mock <EOL> from mock import patch <EOL> from diamond . collector import Collector <EOL> from diskusage import DiskUsageCollector <EOL> class TestDiskUsageCollector ( CollectorTestCase ) : <EOL> def setUp ( self ) : <EOL> config = get_collector_config ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> self . collector = DiskUsageCollector ( config , None ) <EOL> def test_config ( self ) : <EOL> self . assertFalse ( self . collector . config [ '<STR_LIT>' ] ) <EOL> def test_import ( self ) : <EOL> self . assertTrue ( DiskUsageCollector ) <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> def test_get_disk_statistics ( self ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> open_mock = patch_open . start ( ) <EOL> result = self . collector . get_disk_statistics ( ) <EOL> patch_open . stop ( ) <EOL> open_mock . assert_called_once_with ( '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> sorted ( result . keys ( ) ) , <EOL> [ ( <NUM_LIT:8> , <NUM_LIT:0> ) , ( <NUM_LIT:8> , <NUM_LIT:1> ) , ( <NUM_LIT:8> , <NUM_LIT:16> ) , ( <NUM_LIT:8> , <NUM_LIT> ) , ( <NUM_LIT:8> , <NUM_LIT:32> ) , <EOL> ( <NUM_LIT:8> , <NUM_LIT> ) , ( <NUM_LIT:8> , <NUM_LIT> ) , ( <NUM_LIT:8> , <NUM_LIT> ) , ( <NUM_LIT:9> , <NUM_LIT:0> ) ] ) <EOL> return result <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_should_work_with_real_data ( self , publish_mock ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:10> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:20> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> metrics = self . getPickledResults ( '<STR_LIT>' ) <EOL> self . setDocExample ( collector = self . collector . __class__ . __name__ , <EOL> metrics = metrics , <EOL> defaultpath = self . collector . config [ '<STR_LIT:path>' ] ) <EOL> self . assertPublishedMany ( publish_mock , metrics ) <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_verify_supporting_vda_and_xvdb ( self , publish_mock ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:10> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:20> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> metrics = self . getPickledResults ( <EOL> '<STR_LIT>' ) <EOL> self . assertPublishedMany ( publish_mock , metrics ) <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_verify_supporting_md_dm ( self , publish_mock ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:10> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:20> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> metrics = self . getPickledResults ( '<STR_LIT>' ) <EOL> self . assertPublishedMany ( publish_mock , metrics ) <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_verify_supporting_disk ( self , publish_mock ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:10> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:20> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> metrics = self . getPickledResults ( '<STR_LIT>' ) <EOL> self . assertPublishedMany ( publish_mock , metrics ) <EOL> @ patch ( '<STR_LIT>' , Mock ( return_value = True ) ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_service_Time ( self , publish_mock ) : <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT:10> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> patch_open = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( <EOL> return_value = self . getFixture ( <EOL> '<STR_LIT>' ) ) ) <EOL> patch_time = patch ( '<STR_LIT>' , Mock ( return_value = <NUM_LIT> ) ) <EOL> patch_open . start ( ) <EOL> patch_time . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_open . stop ( ) <EOL> patch_time . stop ( ) <EOL> metrics = self . getPickledResults ( '<STR_LIT>' ) <EOL> self . assertPublishedMany ( publish_mock , metrics ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
