<s> from test import CollectorTestCase <EOL> from test import get_collector_config <EOL> from test import unittest <EOL> from mock import patch <EOL> from mock import Mock <EOL> from diamond . collector import Collector <EOL> from flume import FlumeCollector <EOL> class TestFlumeCollector ( CollectorTestCase ) : <EOL> def setUp ( self ) : <EOL> config = get_collector_config ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : <NUM_LIT:10> <EOL> } ) <EOL> self . collector = FlumeCollector ( config , None ) <EOL> def test_import ( self ) : <EOL> self . assertTrue ( FlumeCollector ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_collect_should_work ( self , <EOL> publish_mock , <EOL> publish_gauge_mock , <EOL> publish_counter_mock ) : <EOL> patch_urlopen = patch ( '<STR_LIT>' , <EOL> Mock ( return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> patch_urlopen . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_urlopen . stop ( ) <EOL> metrics = { <EOL> '<STR_LIT>' : <NUM_LIT:0.0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:6> , <EOL> '<STR_LIT>' : <NUM_LIT:7> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:0> <EOL> } <EOL> self . setDocExample ( collector = self . collector . __class__ . __name__ , <EOL> metrics = metrics , <EOL> defaultpath = self . collector . config [ '<STR_LIT:path>' ] ) <EOL> self . assertPublishedMany ( [ publish_mock , <EOL> publish_gauge_mock , <EOL> publish_counter_mock <EOL> ] , metrics ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_blank_should_fail_gracefully ( self , publish_mock ) : <EOL> patch_urlopen = patch ( '<STR_LIT>' , Mock ( <EOL> return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> patch_urlopen . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_urlopen . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> @ patch . object ( Collector , '<STR_LIT>' ) <EOL> def test_invalid_should_fail_gracefully ( self , publish_mock ) : <EOL> patch_urlopen = patch ( <EOL> '<STR_LIT>' , <EOL> Mock ( return_value = self . getFixture ( '<STR_LIT>' ) ) ) <EOL> patch_urlopen . start ( ) <EOL> self . collector . collect ( ) <EOL> patch_urlopen . stop ( ) <EOL> self . assertPublishedMany ( publish_mock , { } ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
