Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_parser.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import io | import io | ||||
from collections import OrderedDict | from collections import OrderedDict | ||||
from nose.tools import istest | |||||
from rest_framework.test import APITestCase | from rest_framework.test import APITestCase | ||||
from swh.deposit.parsers import SWHXMLParser | from swh.deposit.parsers import SWHXMLParser | ||||
class ParsingTest(APITestCase): | class ParsingTest(APITestCase): | ||||
"""Access to main entry point is ok without authentication | """Access to main entry point is ok without authentication | ||||
""" | """ | ||||
@istest | def test_parsing_without_duplicates(self): | ||||
def parsing_without_duplicates(self): | |||||
xml_no_duplicate = io.BytesIO(b'''<?xml version="1.0"?> | xml_no_duplicate = io.BytesIO(b'''<?xml version="1.0"?> | ||||
<entry xmlns="http://www.w3.org/2005/Atom" | <entry xmlns="http://www.w3.org/2005/Atom" | ||||
xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"> | xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"> | ||||
<title>Awesome Compiler</title> | <title>Awesome Compiler</title> | ||||
<codemeta:license> | <codemeta:license> | ||||
<codemeta:name>GPL3.0</codemeta:name> | <codemeta:name>GPL3.0</codemeta:name> | ||||
<codemeta:url>https://opensource.org/licenses/GPL-3.0</codemeta:url> | <codemeta:url>https://opensource.org/licenses/GPL-3.0</codemeta:url> | ||||
</codemeta:license> | </codemeta:license> | ||||
Show All 19 Lines | </entry>''') | ||||
('codemeta:runtimePlatform', 'Python3'), | ('codemeta:runtimePlatform', 'Python3'), | ||||
('codemeta:author', | ('codemeta:author', | ||||
OrderedDict([('codemeta:name', 'author1'), | OrderedDict([('codemeta:name', 'author1'), | ||||
('codemeta:affiliation', 'Inria')])), | ('codemeta:affiliation', 'Inria')])), | ||||
('codemeta:programmingLanguage', 'ocaml'), | ('codemeta:programmingLanguage', 'ocaml'), | ||||
('codemeta:issueTracker', 'http://issuetracker.com')]) | ('codemeta:issueTracker', 'http://issuetracker.com')]) | ||||
self.assertEqual(expected_dict, actual_result) | self.assertEqual(expected_dict, actual_result) | ||||
@istest | def test_parsing_with_duplicates(self): | ||||
def parsing_with_duplicates(self): | |||||
xml_with_duplicates = io.BytesIO(b'''<?xml version="1.0"?> | xml_with_duplicates = io.BytesIO(b'''<?xml version="1.0"?> | ||||
<entry xmlns="http://www.w3.org/2005/Atom" | <entry xmlns="http://www.w3.org/2005/Atom" | ||||
xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"> | xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0"> | ||||
<title>Another Compiler</title> | <title>Another Compiler</title> | ||||
<codemeta:runtimePlatform>GNU/Linux</codemeta:runtimePlatform> | <codemeta:runtimePlatform>GNU/Linux</codemeta:runtimePlatform> | ||||
<codemeta:license> | <codemeta:license> | ||||
<codemeta:name>GPL3.0</codemeta:name> | <codemeta:name>GPL3.0</codemeta:name> | ||||
<codemeta:url>https://opensource.org/licenses/GPL-3.0</codemeta:url> | <codemeta:url>https://opensource.org/licenses/GPL-3.0</codemeta:url> | ||||
Show All 39 Lines |