|
1 | 1 | import copy |
| 2 | +import logging |
2 | 3 | import unittest |
3 | 4 |
|
4 | 5 | from wikibaseintegrator import WikibaseIntegrator, datatypes, wbi_fastrun |
5 | 6 | from wikibaseintegrator.datatypes import BaseDataType, Item |
6 | 7 | from wikibaseintegrator.entities import ItemEntity |
7 | 8 | from wikibaseintegrator.wbi_config import config as wbi_config |
8 | | -from wikibaseintegrator.wbi_enums import ActionIfExists, WikibaseDatatype |
9 | | -from wikibaseintegrator.wbi_fastrun import get_fastrun_container |
| 9 | +from wikibaseintegrator.wbi_enums import WikibaseDatatype |
10 | 10 |
|
11 | 11 | wbi_config['USER_AGENT'] = 'WikibaseIntegrator-pytest/1.0 (test_all.py)' |
12 | 12 |
|
@@ -53,66 +53,22 @@ class TestFastRun(unittest.TestCase): |
53 | 53 | """ |
54 | 54 | some basic tests for fastrun mode |
55 | 55 | """ |
| 56 | + logging.basicConfig(level=logging.DEBUG) |
56 | 57 |
|
57 | 58 | def test_fastrun(self): |
58 | 59 | statements = [ |
59 | | - datatypes.ExternalID(value='P40095', prop_nr='P352'), |
| 60 | + datatypes.ExternalID(value='A0A023PZB3', prop_nr='P352'), |
60 | 61 | datatypes.ExternalID(value='YER158C', prop_nr='P705') |
61 | 62 | ] |
62 | 63 |
|
63 | 64 | frc = wbi_fastrun.FastRunContainer(base_filter=[BaseDataType(prop_nr='P352'), datatypes.Item(prop_nr='P703', value='Q27510868')], base_data_type=datatypes.BaseDataType) |
64 | 65 |
|
65 | | - fastrun_result = frc.write_required(data=statements) |
66 | | - |
67 | | - if fastrun_result: |
68 | | - message = 'fastrun failed' |
69 | | - else: |
70 | | - message = 'successful fastrun' |
| 66 | + fastrun_result = frc.write_required(claims=statements) |
71 | 67 |
|
72 | 68 | # here, fastrun should succeed, if not, test failed |
73 | | - if fastrun_result: |
| 69 | + if not fastrun_result: |
74 | 70 | raise ValueError |
75 | 71 |
|
76 | | - def test_fastrun_label(self): |
77 | | - # tests fastrun label, description and aliases, and label in another language |
78 | | - frc = get_fastrun_container(base_filter=[datatypes.ExternalID(value='/m/02j71', prop_nr='P646')]) |
79 | | - item = WikibaseIntegrator().item.get('Q2') |
80 | | - |
81 | | - assert item.labels.get(language='en') == "Earth" |
82 | | - descr = item.descriptions.get(language='en') |
83 | | - assert len(descr) > 3 |
84 | | - assert "the Earth" in item.aliases.get() |
85 | | - |
86 | | - assert list(frc.get_language_data("Q2", 'en', 'label'))[0] == item.labels.get(language='en') |
87 | | - assert frc.check_language_data("Q2", ['not the Earth'], 'en', 'label') |
88 | | - assert "the Earth" in item.aliases.get() |
89 | | - assert "planet" in item.descriptions.get() |
90 | | - |
91 | | - assert item.labels.get('es') == "Tierra" |
92 | | - |
93 | | - item.descriptions.set(value=descr) |
94 | | - item.descriptions.set(value="fghjkl") |
95 | | - assert item.get_json()['descriptions']['en'] == {'language': 'en', 'value': 'fghjkl'} |
96 | | - item.labels.set(value="Earth") |
97 | | - item.labels.set(value="xfgfdsg") |
98 | | - assert item.get_json()['labels']['en'] == {'language': 'en', 'value': 'xfgfdsg'} |
99 | | - item.aliases.set(values=["fake alias"], action_if_exists=ActionIfExists.APPEND_OR_REPLACE) |
100 | | - assert {'language': 'en', 'value': 'fake alias'} in item.get_json()['aliases']['en'] |
101 | | - |
102 | | - # something that's empty (for now.., can change, so this just makes sure no exception is thrown) |
103 | | - frc.check_language_data("Q2", ['Ewiase'], 'ak', 'label') |
104 | | - frc.check_language_data("Q2", ['not Ewiase'], 'ak', 'label') |
105 | | - frc.check_language_data("Q2", [''], 'ak', 'description') |
106 | | - frc.check_language_data("Q2", [], 'ak', 'aliases') |
107 | | - frc.check_language_data("Q2", ['sdf', 'sdd'], 'ak', 'aliases') |
108 | | - |
109 | | - item.labels.get(language="ak") |
110 | | - item.descriptions.get(language='ak') |
111 | | - item.aliases.get(language="ak") |
112 | | - item.labels.set(value="label", language="ak") |
113 | | - item.descriptions.set(value="d", language="ak") |
114 | | - item.aliases.set(values=["a"], language="ak", action_if_exists=ActionIfExists.APPEND_OR_REPLACE) |
115 | | - |
116 | 72 |
|
117 | 73 | def test_sitelinks(): |
118 | 74 | item = wbi.item.get('Q622901') |
|
0 commit comments