|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +"""Tests for DirectorySyncService.""" |
| 5 | + |
| 6 | +import os |
| 7 | +import sys |
| 8 | + |
| 9 | +import pytest |
| 10 | + |
| 11 | +curpath = os.path.dirname(os.path.abspath(__file__)) |
| 12 | +sys.path[:0] = [os.path.join(curpath, os.pardir)] |
| 13 | + |
| 14 | +from pancloud.directorysync import DirectorySyncService |
| 15 | +from pancloud.httpclient import HTTPClient |
| 16 | +from pancloud.exceptions import RequiredKwargsError, \ |
| 17 | + UnexpectedKwargsError |
| 18 | + |
| 19 | + |
| 20 | +TARPIT = os.environ.get('TARPIT', 'http://10.255.255.1') |
| 21 | + |
| 22 | + |
| 23 | +class TestLoggingService: |
| 24 | + |
| 25 | + def test_entry_points(self): |
| 26 | + |
| 27 | + DirectorySyncService(url=TARPIT).session |
| 28 | + DirectorySyncService(url=TARPIT).kwargs |
| 29 | + DirectorySyncService(url=TARPIT).url |
| 30 | + DirectorySyncService(url=TARPIT).attributes |
| 31 | + DirectorySyncService(url=TARPIT).query |
| 32 | + DirectorySyncService(url=TARPIT).domains |
| 33 | + DirectorySyncService(url=TARPIT).count |
| 34 | + |
| 35 | + def test_repr(self): |
| 36 | + assert repr( |
| 37 | + DirectorySyncService(url='http://', verify=False) |
| 38 | + ) == "DirectorySyncService(url='http://', verify=False)" |
| 39 | + |
| 40 | + def test_required_kwargs(self): |
| 41 | + with pytest.raises(RequiredKwargsError): |
| 42 | + DirectorySyncService() |
| 43 | + |
| 44 | + with pytest.raises(RequiredKwargsError): |
| 45 | + DirectorySyncService(session=None) |
| 46 | + |
| 47 | + def test_unexpected_kwargs(self): |
| 48 | + with pytest.raises(UnexpectedKwargsError): |
| 49 | + DirectorySyncService(url=TARPIT, foo='foo') |
| 50 | + |
| 51 | + def test_session(self): |
| 52 | + session = HTTPClient(url=TARPIT) |
| 53 | + DirectorySyncService(session=session) |
0 commit comments