Example #1
0
def test_initialize_TabularFile_with_bad_alias(content_1, bad_alias):
    """ TabularFile initialization with bad alias - not str. """
    if isinstance(bad_alias, str):
        with pytest.raises(SyntaxError):
            thresh.TabularFile(content=content_1, alias=bad_alias)
    else:
        with pytest.raises(TypeError):
            thresh.TabularFile(content=content_1, alias=bad_alias)
Example #2
0
def jsonfile_1():
    """ A JSON File object """
    return thresh.TabularFile(
        content=OrderedDict({"bar": 4, "foo": 3}), alias="JSON_", length_check=False, namespace_only=True
    )
Example #3
0
def tabularfile_3():
    """ A TabularFile object built on 'content_3'. """
    return thresh.TabularFile(
        content=copy.deepcopy(obj_content_3), alias="tabularfile_3"
    )
Example #4
0
def test_initialize_TabularFile_with_bad_content_3(content_1):
    """ TabularFile initialization with bad content - uneven column lengths. """
    content_1['a'] = np.append(content_1['a'], content_1['a'])
    with pytest.raises(IndexError):
        thresh.TabularFile(content=content_1)
Example #5
0
def test_initialize_TabularFile_with_bad_content_2(content_1):
    """ TabularFile initialization with bad content - non-text key. """
    content_1[3.14] = content_1['a']
    with pytest.raises(KeyError):
        thresh.TabularFile(content=content_1)
Example #6
0
def test_initialize_TabularFile_with_bad_content_1():
    """ TabularFile initialization with bad content - not OrderedDict. """
    with pytest.raises(TypeError):
        thresh.TabularFile(content=3.14)
Example #7
0
def test_initialize_TabularFile_with_alias(content_1):
    """ Do a basic initialization of a TabularFile. """
    alias = "A"
    tabularfile = thresh.TabularFile(content=content_1, alias=alias)
    assert tabularfile.alias == alias
    assert tabularfile.content == content_1
Example #8
0
def test_initialize_TabularFile_no_alias(content_1):
    """ Do a basic initialization of a TabularFile without an alias. """
    tabularfile = thresh.TabularFile(content=content_1)
    assert tabularfile.alias is None
    assert tabularfile.content == content_1
Example #9
0
def test_initialize_TabularFile_no_content():
    """ Do a basic initialization of a TabularFile without content. """
    tabularfile = thresh.TabularFile()
    assert tabularfile.alias is None
    assert tabularfile.content == OrderedDict()