示例#1
0
 def test_generation_with_no_about_resource(self):
     location = get_test_loc('gen/inv2.csv')
     base_dir = get_temp_dir()
     errors, abouts = gen.generate(location, base_dir)
     expected = OrderedDict([(u'.', None)])
     assert abouts[0].about_resource.value == expected
     assert len(errors) == 1
 def test_generation_with_no_about_resource(self):
     location = get_test_loc('test_gen/inv2.csv')
     base_dir = get_temp_dir()
     errors, abouts = gen.generate(location, base_dir)
     expected = OrderedDict([('.', None)])
     assert abouts[0].about_resource.value == expected
     assert len(errors) == 1
示例#3
0
 def test_generation_dir_endswith_space(self):
     location = get_test_loc(
         'inventory/complex/about_file_path_dir_endswith_space.csv')
     base_dir = get_temp_dir()
     errors, _abouts = gen.generate(location, base_dir)
     expected_errors_msg = 'contains directory name ends with spaces which is not allowed. Generation skipped.'
     assert errors
     assert len(errors) == 1
     assert expected_errors_msg in errors[0].message
示例#4
0
 def test_generation_dir_endswith_space(self):
     location = get_test_loc('inventory/complex/about_file_path_dir_endswith_space.csv')
     base_dir = get_temp_dir()
     errors, _abouts = gen.generate(location, base_dir)
     expected_errors_msg1 = 'contains directory name ends with spaces which is not allowed. Generation skipped.'
     expected_errors_msg2 = 'Field about_resource'
     assert errors
     assert len(errors) == 2
     assert expected_errors_msg1 in errors[0].message or expected_errors_msg1 in errors[1].message
     assert expected_errors_msg2 in errors[0].message or expected_errors_msg2 in errors[1].message
示例#5
0
    def test_generation_with_no_about_resource_reference_no_resource_validation(
            self):
        location = get_test_loc('gen/inv3.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        expected = OrderedDict([(u'test.tar.gz', None)])

        assert abouts[0].about_resource.value == expected
        assert len(errors) == 1
示例#6
0
    def test_generation_with_no_about_resource_reference(self):
        location = get_test_loc('gen/inv3.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        expected = OrderedDict([(u'test.tar.gz', None)])

        assert abouts[0].about_resource.value == expected
        assert len(errors) == 1
        msg = u'Field about_resource'
        assert msg in errors[0].message
示例#7
0
    def test_generation_with_no_about_resource_reference(self):
        location = get_test_loc('gen/inv3.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        expected = [u'test.tar.gz']

        assert abouts[0].about_resource.value == expected
        assert len(errors) == 1
        msg = u'Field about_resource_path'
        assert msg in errors[0].message
    def test_boolean_value_not_lost(self):
        location = get_test_loc('test_gen/inv6.csv')
        base_dir = get_temp_dir()

        _errors, abouts = gen.generate(location, base_dir)

        in_mem_result = [a.dumps() for a in abouts][0]
        expected = (u'about_resource: .\n'
                    u'name: AboutCode\n'
                    u'version: 0.11.0\n'
                    u'redistribute: yes\n'
                    u'attribute: yes\n'
                    u'modified: no\n')
        assert expected == in_mem_result
    def test_generate_multi_lic_issue_444(self):
        location = get_test_loc('test_gen/multi_lic_issue_444/test1.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)

        result = [a.dumps() for a in abouts][0]
        expected = ('''about_resource: test.c
name: test.c
licenses:
  - key: License1
    file: LIC1.LICENSE, LIC2.LICENSE
''')
        assert expected == result
示例#10
0
    def test_generate_not_overwrite_original_license_file(self):
        location = get_test_loc('test_gen/inv5.csv')
        base_dir = get_temp_dir()
        reference_dir = None
        fetch_license = ['url', 'lic_key']

        _errors, abouts = gen.generate(location, base_dir, reference_dir,
                                       fetch_license)

        result = [a.dumps() for a in abouts][0]
        expected = ('about_resource: .\n'
                    'name: AboutCode\n'
                    'version: 0.11.0\n'
                    'licenses:\n'
                    '    -   file: this.LICENSE\n')
        assert expected == result
示例#11
0
    def test_generate_not_overwrite_original_license_file(self):
        location = get_test_loc('gen/inv5.csv')
        base_dir = get_temp_dir()
        license_notice_text_location = None
        fetch_license = ['url', 'lic_key']

        _errors, abouts = gen.generate(location, base_dir, license_notice_text_location, fetch_license)

        in_mem_result = [a.dumps(use_mapping=False, mapping_file=False, with_absent=False, with_empty=False)
                        for a in abouts][0]
        expected = (u'about_resource: .\n'
                    u'name: AboutCode\n'
                    u'version: 0.11.0\n'
                    u'licenses:\n'
                    u'    -   file: this.LICENSE\n')
        assert expected == in_mem_result
示例#12
0
    def test_generate_not_overwrite_original_license_file(self):
        location = get_test_loc('gen/inv5.csv')
        base_dir = get_temp_dir()
        license_notice_text_location = None
        fetch_license = ['url', 'lic_key']

        errors, abouts = gen.generate(location, base_dir,
                                      license_notice_text_location,
                                      fetch_license)

        in_mem_result = [
            a.dumps(with_absent=False, with_empty=False) for a in abouts
        ][0]
        expected = (u'about_resource: .\n'
                    u'name: AboutCode\n'
                    u'about_resource_path: .\n'
                    u'version: 0.11.0\n'
                    u'license_file: this.LICENSE\n')
        assert expected == in_mem_result
示例#13
0
    def test_generate(self):
        location = get_test_loc('gen/inv.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        msg1 = u'Field custom1 is not a supported field and is ignored.'
        msg2 = u'Field about_resource'

        assert msg1 in errors[0].message
        assert msg2 in errors[1].message

        in_mem_result = [a.dumps(use_mapping=False, mapping_file=False, with_absent=False, with_empty=False)
                        for a in abouts][0]
        expected = (u'about_resource: .\n'
                    u'name: AboutCode\n'
                    u'version: 0.11.0\n'
                    u'description: |-\n'
                    u'    multi\n'
                    u'    line\n')
        assert expected == in_mem_result
示例#14
0
    def test_generate(self):
        location = get_test_loc('gen/inv.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        msg1 = u'Field custom1 is not a supported field and is ignored.'
        msg2 = u'Field about_resource_path'

        assert msg1 in errors[0].message
        assert msg2 in errors[1].message

        in_mem_result = [
            a.dumps(with_absent=False, with_empty=False) for a in abouts
        ][0]
        expected = (u'about_resource: .\n'
                    u'name: AboutCode\n'
                    u'about_resource_path: .\n'
                    u'version: 0.11.0\n'
                    u'description: |\n'
                    u'    multi\n'
                    u'    line\n')
        assert expected == in_mem_result
示例#15
0
    def test_generate(self):
        location = get_test_loc('test_gen/inv.csv')
        base_dir = get_temp_dir()

        errors, abouts = gen.generate(location, base_dir)
        msg1 = 'Field custom1 is a custom field.'
        msg2 = 'Field about_resource'

        assert msg1 in errors[0].message
        assert msg2 in errors[1].message

        result = [a.dumps() for a in abouts][0]
        expected = ('''about_resource: .
name: AboutCode
version: 0.11.0
description: |
  multi
  line
custom1: |
  multi
  line
''')
        assert expected == result