def test_default(*_): profile_file_data = {'_default': {'profile': 'Profile Name'}} result = extract_generate_data(profile_file_data) expected = GenerateData() expected.profile_name = 'Profile Name' assert expected == result
def test_section(*_): profile_file_data = {'_section': {'profile': 'Profile Name'}} result = extract_generate_data(profile_file_data, '_section') expected = GenerateData() expected.profile_name = 'Profile Name' assert expected == result
def test_str_str(*_): generate_data = GenerateData() generate_data.profile_name = 'a' generate_data.template_name = 'b' result = str(generate_data) expected = "GenerateData('a', 'b', None, None)" assert expected == result
def test_no_profile_name(*_): input_path = '' output_path = '' default = GenerateData() common = GenerateData() profile_file_data = {'service': {'pass': True}} with pytest.raises(AmqcfgBatchException): generate_all_profiles(input_path, output_path, default, common, profile_file_data)
def test_advanced(*_): input_path = '' output_path = 'test' default = GenerateData() default.profile_name = 'test2' common = GenerateData() profile_file_data = { '_default': { 'profile': 'test2', }, 'service': { 'profile': 'test', }, 'service2': { 'tuning_files': ['a'] }, 'service3': { 'template': 'My Template', 'tuning': { 'a': 1 } } } generate_all_profiles(input_path, output_path, default, common, profile_file_data) import os calls = [ mock.call(profile='test', template=None, output_path=os.path.join('test', 'service'), tuning_files_list=None, tuning_data_list=None), mock.call(profile='test2', template=None, output_path=os.path.join('test', 'service2'), tuning_files_list=['a'], tuning_data_list=None), mock.call(profile='test2', template='My Template', output_path=os.path.join('test', 'service3'), tuning_files_list=None, tuning_data_list=[{ 'a': 1 }]), ] # noinspection PyUnresolvedReferences amqcfg.amqcfg.generate.assert_has_calls(calls, any_order=True)
def test_empty(*_): profile_file_data = {} result = extract_generate_data(profile_file_data) expected = GenerateData() assert expected == result
def test_str_none(*_): generate_data = GenerateData() result = str(generate_data) expected = 'GenerateData(None, None, None, None)' assert expected == result
def test_default(*_): default = GenerateData() default.profile_name = 'Default Profile' default.template_name = 'Default Template' default.tuning_files = ['Default Tuning Files'] default.tuning_data = {'Tuning Data': 'Default', 'Default': 'Tuning data'} common = GenerateData() profile = GenerateData() result = prioritize_generate_data(profile, common, default) expected = default assert expected == result
def test_basic(*_): input_path = '' output_path = '' default = GenerateData() common = GenerateData() profile_file_data = { 'service': { 'profile': 'test', } } generate_all_profiles(input_path, output_path, default, common, profile_file_data) # noinspection PyUnresolvedReferences amqcfg.amqcfg.generate.assert_called_with( profile='test', template=None, output_path=None, tuning_files_list=None, tuning_data_list=None, )
def test_profile(*_): default = GenerateData() common = GenerateData() profile = GenerateData() profile.profile_name = 'Profile Profile' profile.template_name = 'Profile Template' profile.tuning_files = ['Profile Tuning Files'] profile.tuning_data = {'Tuning Data': 'Profile', 'Profile': 'Tuning data'} expected = profile result = prioritize_generate_data(profile, common, default) assert expected == result
def test_common(*_): default = GenerateData() common = GenerateData() common.profile_name = 'Common Profile' common.template_name = 'Common Template' common.tuning_files = ['Common Tuning Files'] common.tuning_data = {'Tuning Data': 'Common', 'Common': 'Tuning data'} profile = GenerateData() expected = common result = prioritize_generate_data(profile, common, default) assert expected == result
def test_data(*_): profile_file_data = { '_default': { 'profile': 'Profile Name', 'template': 'Template Name', 'tuning_files': ['Tuning Files'], 'tuning': { 'a': 1, } } } result = extract_generate_data(profile_file_data) expected = GenerateData() expected.profile_name = 'Profile Name' expected.template_name = 'Template Name' expected.tuning_files = ['Tuning Files'] expected.tuning_data = {'a': 1} assert expected == result
def test_neq_tuning_files(*_): data1 = GenerateData() data1.profile_name = 'Profile Name' data1.template_name = 'Template Name' data1.tuning_files = ['Tuning fil'] data1.tuning_data = {'a': 1} data2 = GenerateData() data2.profile_name = 'Profile Name' data2.template_name = 'Template Name' data2.tuning_files = ['Tuning file'] data2.tuning_data = {'a': 1} assert data1 != data2
def test_eq_empty(*_): data1 = GenerateData() data2 = GenerateData() assert data1 == data2
def test_default_common_profile(*_): default = GenerateData() default.profile_name = 'Default Profile' default.template_name = 'Default Template' default.tuning_files = ['Default Tuning Files'] default.tuning_data = {'Tuning Data': 'Default', 'Default': 'Tuning data'} common = GenerateData() common.profile_name = 'Common Profile' common.template_name = 'Common Template' common.tuning_files = ['Common Tuning Files'] common.tuning_data = {'Tuning Data': 'Common', 'Common': 'Tuning data'} profile = GenerateData() profile.profile_name = 'Profile Profile' profile.template_name = 'Profile Template' profile.tuning_files = ['Profile Tuning Files'] profile.tuning_data = {'Tuning Data': 'Profile', 'Profile': 'Tuning data'} expected = GenerateData() expected.profile_name = profile.profile_name expected.template_name = profile.template_name expected.tuning_files = [] + common.tuning_files + profile.tuning_files expected.tuning_data = {} expected.tuning_data.update(common.tuning_data) expected.tuning_data.update(profile.tuning_data) result = prioritize_generate_data(profile, common, default) assert expected == result
del filename yield { '_default': { 'tuning_files': ['a', 'b'] }, '_common': { 'profile': 'Profile Name' } } yield { '_default': { 'tuning_files': ['c', 'd'] }, '_common': { 'profile': 'Profile Name 2' } } fake_default_one = GenerateData() fake_default_one.tuning_files = ['a', 'b'] fake_common_one = GenerateData() fake_common_one.profile_name = 'Profile Name' fake_default_two = GenerateData() fake_default_two.tuning_files = ['c', 'd'] fake_common_two = GenerateData() fake_common_two.profile_name = 'Profile Name 2'