Пример #1
0
    def test_appstream_with_multiple_launchables(self):
        with open('foo.metainfo.xml', 'w') as f:
            f.write(textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <launchable type="desktop-id">
                    com.example.test-app1.desktop
                  </launchable>
                  <launchable type="test-wrong-type">
                    dummy
                  </launchable>
                  <launchable type="desktop-id">
                    com.example.test-app2.desktop
                  </launchable>
                  <launchable type="desktop-id">
                    unexisting
                  </launchable>
                </component>"""))

        os.makedirs('usr/local/share/applications/com.example.test/')
        open('usr/local/share/applications/com.example.test/app1.desktop',
             'w').close()
        open('usr/local/share/applications/com.example.test/app2.desktop',
             'w').close()

        expected = ExtractedMetadata(
            desktop_file_paths=[
                'usr/local/share/applications/com.example.test/app1.desktop',
                'usr/local/share/applications/com.example.test/app2.desktop'])

        self.assertThat(
            appstream.extract('foo.metainfo.xml'), Equals(expected))
Пример #2
0
    def test(self, tmp_work_path, import_statement, method, params):
        self.create_setuppy(import_statement, method, params)

        expected = ExtractedMetadata(**params)
        actual = setuppy.extract("setup.py", workdir=".")

        assert str(actual) == str(expected)
        assert actual == expected
Пример #3
0
    def test_appstream(self):
        with open('foo.metainfo.xml', 'w') as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <{key}>test-{key}</{key}>
                </component>""".format(key=self.key)))

        kwargs = {self.key: 'test-{}'.format(self.key)}
        expected = ExtractedMetadata(**kwargs)

        self.assertThat(appstream.extract('foo.metainfo.xml'),
                        Equals(expected))
Пример #4
0
    def test_appstream_with_launchable(self):
        with open('foo.metainfo.xml', 'w') as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <launchable type="desktop-id">
                    com.example.test-app.desktop
                  </launchable>
                </component>"""))

        expected = ExtractedMetadata(
            desktop_file_ids=['com.example.test-app.desktop'])

        self.assertThat(appstream.extract('foo.metainfo.xml'),
                        Equals(expected))
Пример #5
0
    def test_appstream_with_launchable(self):
        with open("foo.metainfo.xml", "w") as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <launchable type="desktop-id">
                    com.example.test-app.desktop
                  </launchable>
                </component>"""))

        os.makedirs(os.path.dirname(self.desktop_file_path))
        open(self.desktop_file_path, "w").close()

        expected = ExtractedMetadata(
            desktop_file_paths=[self.desktop_file_path])

        self.assertThat(appstream.extract("foo.metainfo.xml"),
                        Equals(expected))
Пример #6
0
    def test_appstream(self):
        file_name = 'foo.{}'.format(self.file_extension)
        attributes = ' '.join('{attribute_name}="{attribute_value}"'.format(
            attribute_name=attribute,
            attribute_value=self.attributes[attribute])
                              for attribute in self.attributes)
        with open(file_name, 'w') as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <{key} {attributes}>{value}</{key}>
                </component>""".format(key=self.key,
                                       value=self.value,
                                       attributes=attributes)))

        kwargs = {self.key: self.value}
        expected = ExtractedMetadata(**kwargs)

        self.assertThat(appstream.extract(file_name), Equals(expected))
Пример #7
0
    def test(self, tmp_work_path, file_extension, key, attributes, param_name,
             value, expect):
        file_name = f"foo.{file_extension}"
        attributes = " ".join('{attribute_name}="{attribute_value}"'.format(
            attribute_name=attribute, attribute_value=attributes[attribute])
                              for attribute in attributes)
        with open(file_name, "w") as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <{key} {attributes}>{value}</{key}>
                </component>""".format(key=key,
                                       value=value,
                                       attributes=attributes)))

        open("icon.png", "w").close()
        kwargs = {param_name: expect}
        expected = ExtractedMetadata(**kwargs)

        assert appstream.extract(file_name, workdir=".") == expected
Пример #8
0
    def test_appstream(self):
        file_name = "foo.{}".format(self.file_extension)
        attributes = " ".join('{attribute_name}="{attribute_value}"'.format(
            attribute_name=attribute,
            attribute_value=self.attributes[attribute])
                              for attribute in self.attributes)
        with open(file_name, "w") as f:
            f.write(
                textwrap.dedent("""\
                <?xml version="1.0" encoding="UTF-8"?>
                <component>
                  <{key} {attributes}>{value}</{key}>
                </component>""".format(key=self.key,
                                       value=self.value,
                                       attributes=attributes)))

        open("icon.png", "w").close()
        kwargs = {self.param_name: self.expect}
        expected = ExtractedMetadata(**kwargs)

        self.assertThat(appstream.extract(file_name, workdir="."),
                        Equals(expected))
Пример #9
0
 def test_info_extraction(self):
     expected = ExtractedMetadata(**self.params)
     actual = setuppy.extract("setup.py")
     self.assertThat(str(actual), Equals(str(expected)))
     self.assertThat(actual, Equals(expected))
Пример #10
0
 def _expect_icon(self, icon):
     expected = ExtractedMetadata(icon=icon)
     actual = appstream.extract("foo.appdata.xml", workdir=".")
     self.assertThat(actual.get_icon(), Equals(expected.get_icon()))