def test_parse_ttl_file_with_begin(self, parse_ttl_string): EXPECTED_STRING = ":Human a owl:Class ." mocked_open = mock_open() mocked_open.return_value = StringIO(TTL_STRING) with patch('__builtin__.open', mocked_open): parse_ttl_file(mocked_open, begin=6) parse_ttl_string.assert_called_with(EXPECTED_STRING)
def test_parse_ttl_file_with_begin_and_end(self, parse_ttl_string): EXPECTED_STRING = "@prefix : <http://example.onto/> .\n" mocked_open = mock_open() mocked_open.return_value = StringIO(TTL_STRING) with patch('__builtin__.open', mocked_open): parse_ttl_file(mocked_open, begin=1, end=2) parse_ttl_string.assert_called_with(EXPECTED_STRING)
def test_parse_facts_from_string(self, parse_ttl_string): mocked_open = mock_open() mocked_open.side_effect = IOError with patch("diderot.utils.urlopen", mocked_open): parse_facts(TTL_STRING) parse_ttl_string.assert_called_with(TTL_STRING)
def test_parse_ttl_file(self, parse_ttl_string): mocked_open = mock_open() mocked_open.return_value = StringIO(TTL_STRING) with patch('__builtin__.open', mocked_open): parse_ttl_file(mocked_open) parse_ttl_string.assert_called_with(TTL_STRING)
def test_parse_facts_from_uri(self, parse_ttl_string): mocked_open = mock_open() mocked_open.return_value = StringIO(TTL_STRING) with patch("diderot.utils.urlopen", mocked_open): parse_facts("http://test") parse_ttl_string.assert_called_with(TTL_STRING)