• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenDataServices / flatten-tool / 10472443814

20 Aug 2024 01:21PM UTC coverage: 95.784% (+0.07%) from 95.71%
10472443814

Pull #456

github

Bjwebb
xml input: Ensure namespaces don't break sheet titles

Namespaces contain colons which aren't permitted in Excel sheet names.
Pull Request #456: Fix namespace unflattening

31 of 33 new or added lines in 3 files covered. (93.94%)

2 existing lines in 1 file now uncovered.

3408 of 3558 relevant lines covered (95.78%)

11.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/flattentool/tests/test_input.py
1
# -*- coding: utf-8 -*-
2
"""
2✔
3
Tests of functions in input.py
4
Tests of SpreadsheetInput class and its children are in test_input_SpreadsheetInput*.py
5
"""
6
from __future__ import unicode_literals
12✔
7

8
import csv
12✔
9
import io
12✔
10
import sys
12✔
11

12
import pytest
12✔
13

14
from flattentool.input import NullCharacterFilter, path_search
12✔
15

16

17
def test_path_search():
12✔
18
    goal_dict = {}
12✔
19
    assert goal_dict is not {}  # following tests rely on this
12✔
20
    assert path_search(goal_dict, []) is goal_dict
12✔
21
    assert path_search({"testA": goal_dict}, ["testA"]) is goal_dict
12✔
22
    assert (
12✔
23
        path_search({"a1": {"b1": {"c1": goal_dict}}}, ["a1", "b1", "c1"]) is goal_dict
24
    )
25
    assert (
12✔
26
        path_search(
27
            {"a1": {"b1": {"c1": goal_dict}}},
28
            ["a1", "b1[]"],
29
            id_fields={"a1/b1[]/id": "c1"},
30
        )
31
        is goal_dict
32
    )
33
    assert (
12✔
34
        path_search(
35
            {"a1": {"b1": {"c1": goal_dict}}},
36
            ["a1[]", "c1"],
37
            id_fields={"a1[]/id": "b1"},
38
        )
39
        is goal_dict
40
    )
41
    # Top is always assumed to be an array
42
    assert (
12✔
43
        path_search(
44
            {"a1": {"b1": {"c1": goal_dict}}},
45
            ["a1", "c1"],
46
            id_fields={"a1/id": "b1"},
47
            top=True,
48
        )
49
        is goal_dict
50
    )
51

52

53
def test_null_character_filter():
12✔
54
    # https://bugs.python.org/issue27580
55
    if sys.version_info < (3, 11):
12✔
UNCOV
56
        with pytest.raises(Exception):
8✔
UNCOV
57
            next(csv.reader(io.StringIO("\0")))
8✔
58

59
    try:
12✔
60
        next(csv.reader(NullCharacterFilter(io.StringIO("\0"))))
12✔
61
    except Exception as e:
×
62
        pytest.fail(str(e))
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc