Exemplo n.º 1
0
def test_has_classification(m_os_isfile):
    """
    Test that method returns true when the file exists on disk.
    """
    given_tn = 'test'
    given_uuid = 0
    given_subdir = '/some/test'
    expected_fp = '/some/test/test.0.classification.pickle'

    # Simulate the expected file existing and nothing else.
    m_os_isfile.side_effect = lambda p: p == expected_fp

    e = FileClassificationElement(given_tn, given_uuid, given_subdir)

    assert e.has_classifications() is True
    m_os_isfile.assert_called_once_with(expected_fp)
Exemplo n.º 2
0
def test_has_classification_no_file(m_os_isfile):
    """
    Test that has_classification returns False when the target file being
    checked does not exist on the filesystem.
    """
    given_tn = 'test'
    given_uuid = 0
    given_subdir = '/some/test'
    expected_fp = '/some/test/test.0.classification.pickle'

    # Simulate the expected file existing and nothing else.
    m_os_isfile.return_value = False

    e = FileClassificationElement(given_tn, given_uuid, given_subdir)

    assert e.has_classifications() is False
    m_os_isfile.assert_called_once_with(expected_fp)