本文整理汇总了Python中api.configuration_api.ConfigurationAPI类的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI类的具体用法?Python ConfigurationAPI怎么用?Python ConfigurationAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_available_audio_options_should_include_recomended_options
def test_get_available_audio_options_should_include_recomended_options(self, mock_load, mock_get_valid_sampling_options):
audio_options = {
"input" : [{'sample_rate' : 48000, 'depth': '16 bit' }],
"output": [{'sample_rate' : 48000, 'depth': '16 bit' }]
}
expected_in = AudioSetting(48000,'16 bit', current = True)
expected_in.set_recommended()
expected_out = AudioSetting(48000,'16 bit', current = True)
expected_out.set_recommended()
expected = {
"inputs" : [expected_in],
"outputs": [expected_out]
}
mock_get_valid_sampling_options.return_value = audio_options
mock_load.return_value = self.DEFAULT_CONFIG
capi = ConfigurationAPI(ConfigurationManager())
capi.load_printer("Printer")
actual = capi.get_available_audio_options()
self.assertListContentsEqual(expected['inputs'],actual['inputs'])
self.assertListContentsEqual(expected['outputs'],actual['outputs'])
示例2: AddPrinterUI
class AddPrinterUI(PeachyFrame):
def initialize(self):
self.grid()
self._configuration_api = ConfigurationAPI(self._configuration_manager)
self._printer_name = StringVar()
Label(self, text = "Enter a name for your printer" ).grid(column=0,row=10)
Entry(self, textvariable = self._printer_name).grid(column=1, row=10)
Label(self).grid(column=1,row=20)
Button(self, text ="Save", command = self._save).grid(column=1,row=30, sticky=N+S+E)
Button(self,text=u"Cancel", command=self._back).grid(column=0,row=100)
self.update()
def _save(self):
printer_name = self._printer_name.get()
self._configuration_api.add_printer(printer_name)
self.navigate(SetupUI)
def _back(self):
self.navigate(SetupUI)
def close(self):
pass
示例3: test_get_speed_at_height_returns_a_correct_height
def test_get_speed_at_height_returns_a_correct_height(self, mock_load):
mock_load.return_value = self.DEFAULT_CONFIG
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
speed = configuration_API.get_speed_at_height(0,1,10,20,0.5)
self.assertEquals(15, speed)
示例4: test_get_cure_test_returns_a_layer_generator
def test_get_cure_test_returns_a_layer_generator(self, mock_load):
mock_load.return_value = self.DEFAULT_CONFIG
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
cure_test = configuration_API.get_cure_test(0,1,1,2)
cure_test.next()
示例5: test_sublayer_height_mm_returns_theight
def test_sublayer_height_mm_returns_theight(self, mock_load):
expected = 7.0
mock_load.return_value = { 'name':'name', 'sublayer_height_mm': expected }
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
self.assertEquals(expected,configuration_API.get_sublayer_height_mm())
示例6: test_get_available_audio_options_sets_currently_selected
def test_get_available_audio_options_sets_currently_selected(self, mock_load, mock_get_valid_sampling_options):
audio_options = {
"input" : [{'sample_rate' : 48000, 'depth': '16 bit' },{'sample_rate' : 44100, 'depth': '16 bit' }],
"output": [{'sample_rate' : 48000, 'depth': '16 bit' },{'sample_rate' : 44100, 'depth': '16 bit' }]
}
mock_get_valid_sampling_options.return_value = audio_options
config = self.DEFAULT_CONFIG.copy()
config['input_bit_depth'] = '16 bit'
config['input_sample_frequency'] = 44100
config['output_bit_depth'] = '16 bit'
config['output_sample_frequency'] = 44100
mock_load.return_value = config
capi = ConfigurationAPI(ConfigurationManager())
capi.load_printer("Printer")
actual = capi.get_available_audio_options()
in1 = AudioSetting(44100,'16 bit', current = True)
in2 = AudioSetting(48000,'16 bit', recommended = True)
out1 = AudioSetting(44100,'16 bit', current = True)
out2 = AudioSetting(48000,'16 bit', recommended = True)
self.assertListContentsEqual([in1, in2],actual['inputs'])
self.assertListContentsEqual([out1, out2],actual['outputs'])
示例7: test_add_printer_should_save_itself
def test_add_printer_should_save_itself(self, mock_save, mock_new):
capi = ConfigurationAPI(ConfigurationManager())
mock_new.return_value = "Some Printer Config"
capi.add_printer("NewName")
mock_new.assert_called_with("NewName")
mock_save.assert_called_with("Some Printer Config")
示例8: test_load_printer_calls_load
def test_load_printer_calls_load(self, mock_load):
printer_name = 'MegaPrint'
mock_load.return_value = { 'name':printer_name}
capi = ConfigurationAPI(ConfigurationManager())
capi.load_printer(printer_name)
mock_load.assert_called_with(printer_name)
示例9: test_get_dripper_type_should_return_current_type
def test_get_dripper_type_should_return_current_type(self, mock_load):
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.default_config
configuration_API.load_printer('Printer')
actual = configuration_API.get_dripper_type()
self.assertEquals(self.default_config.dripper.dripper_type, actual)
示例10: test_start_counting_drips_should_start_getting_drips
def test_start_counting_drips_should_start_getting_drips(self, mock_start,mock_load,mock_save):
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.DEFAULT_CONFIG
configuration_API.load_printer('printer')
configuration_API.start_counting_drips()
mock_start.assert_called_with()
示例11: test_current_printer_returns_printer_name
def test_current_printer_returns_printer_name(self, mock_new, mock_save):
capi = ConfigurationAPI(ConfigurationManager())
mock_new.return_value = { 'name' : 'Spam' }
capi.add_printer('Spam')
actual = capi.current_printer()
self.assertEqual('Spam', actual)
示例12: test_get_emulated_drips_per_second_should_return
def test_get_emulated_drips_per_second_should_return(self, mock_load):
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.default_config
configuration_API.load_printer('Printer')
actual = configuration_API.get_emulated_drips_per_second()
self.assertEquals(self.default_config.dripper.emulated_drips_per_second, actual)
示例13: test_get_laser_thickness_mm_returns_thickness
def test_get_laser_thickness_mm_returns_thickness(self, mock_load):
expected = 7.0
config = self.DEFAULT_CONFIG.copy()
config['laser_thickness_mm'] = expected
mock_load.return_value = config
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
self.assertEquals(expected,configuration_API.get_laser_thickness_mm())
示例14: test_get_laser_thickness_mm_returns_thickness
def test_get_laser_thickness_mm_returns_thickness(self, mock_load):
expected = 7.0
config = self.default_config
config.options.laser_thickness_mm = expected
mock_load.return_value = config
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
self.assertEquals(expected,configuration_API.get_laser_thickness_mm())
示例15: test_get_max_lead_distance_mm_returns_max_lead_distance
def test_get_max_lead_distance_mm_returns_max_lead_distance(self, mock_load):
expected = 0.4
config = self.default_config
config.dripper.max_lead_distance_mm = expected
mock_load.return_value = config
configuration_API = ConfigurationAPI(ConfigurationManager())
configuration_API.load_printer("test")
self.assertEquals(expected,configuration_API.get_max_lead_distance_mm())