Пример #1
0
def test_delete_user():
    """
    Test that users can be deleted
    """
    client = LicensingAPIClient('test_user', TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    client.users.delete_user("3d4a29f7-aedc-46b8-bada-f84d04f98679")
Пример #2
0
def test_cancel_invite():
    """
    Test that invites can be updated
    """
    client = LicensingAPIClient('test_invite', TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    client.invites.cancel_invite("bc30c000-eeee-11e6-8088-111111111111")
Пример #3
0
def test_get_user():
    """
    Test that you can fetch a single user
    """
    client = LicensingAPIClient('test_user', TEST_API_KEY)

    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    user = client.users.get_user("3d4a29f7-aedc-46b8-bada-f84d04f98679")
    assert user.id == "3d4a29f7-aedc-46b8-bada-f84d04f98679"
Пример #4
0
def test_get_team():
    """
    Test that you can fetch a single team
    """
    client = LicensingAPIClient('test_team', TEST_API_KEY)

    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    team = client.teams.get_team("2b947975-482a-4791-aa40-e199b3ca8738")
    assert team.id == "2b947975-482a-4791-aa40-e199b3ca8738"
    assert team.name == 'FED'
Пример #5
0
def test_update_user():
    """
    Test that users can be updated
    """
    client = LicensingAPIClient('test_user', TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)

    client.users.update_user(id="3d4a29f7-aedc-46b8-bada-f84d04f98679",
                             team_id="1234512-aedc-46b8-bada-f84d04f98679",
                             note="test note")
    assert True
Пример #6
0
def test_get_all_teams():
    """
    Test that get all invites returns properly formatted models
    """
    client = LicensingAPIClient(TEST_PLAN, TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    teams = client.teams.get_all_teams()
    assert len(teams) == 2
    assert teams[0].id == '2b947975-482a-4791-aa40-e199b3ca8738'
    assert teams[0].name == 'FED'
    assert str(teams[0]) == "Team 'FED' (2b947975-482a-4791-aa40-e199b3ca8738)"
Пример #7
0
def test_create_invite():
    """
    Test that invites can be issued
    """
    client = LicensingAPIClient('test_create_invite', TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)

    invite = client.invites.invite_user('*****@*****.**', None, "test note")
    assert invite.id == "bc30c000-eeee-11e6-8088-111111111111"
    assert invite.email == '*****@*****.**'
    assert invite.team_id is None
    assert invite.note == 'Services'
    assert invite.send_date.timestamp == 1483488000
    assert invite.expires_on.timestamp == 1487376000
Пример #8
0
def test_get_invite():
    """
    Test that get all invites returns properly formatted models
    """
    client = LicensingAPIClient('test_invite', TEST_API_KEY)

    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    invite = client.invites.get_invite("bc30c000-eeee-11e6-8088-111111111111")
    assert invite.id == "bc30c000-eeee-11e6-8088-111111111111"
    assert invite.email == '*****@*****.**'
    assert invite.team_id is None
    assert invite.note == 'Services'
    assert invite.send_date.timestamp == 1483488000
    assert invite.expires_on.timestamp == 1487376000
Пример #9
0
def test_get_all_users():
    """
    Test that get all users returns properly formatted models
    """
    client = LicensingAPIClient(TEST_PLAN, TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    users = client.users.get_all_users()
    assert len(users) == 2
    assert users[0].id == "0bbdccac-dad1-4488-a69d-2ea78bf43280"
    assert users[0].team_id == "2b947975-482a-4791-aa40-e199b3ca8738"
    assert users[0].first_name == "first-25"
    assert users[0].last_name == "last-25"
    assert users[0].email == "*****@*****.**"
    assert users[0].note == 'test note'
    assert users[0].start_date.timestamp == 1463020267
    assert str(users[0]) == "User 'first-25 last-25' [email protected] " \
        "(0bbdccac-dad1-4488-a69d-2ea78bf43280)"
Пример #10
0
def test_get_all_invites():
    """
    Test that get all invites returns properly formatted models
    """
    client = LicensingAPIClient(TEST_PLAN, TEST_API_KEY)
    special_adapter = Adapter('tests/fixtures')
    client.session.mount('https://app.pluralsight.com', special_adapter)
    invites = client.invites.get_all_invites()
    assert len(invites) == 2
    assert invites[0].id == "bc30c000-eeee-11e6-8088-111111111111"
    assert invites[0].email == '*****@*****.**'
    assert invites[0].team_id is None
    assert invites[0].note == 'Services'
    assert invites[0].send_date.timestamp == 1483488000
    assert invites[0].expires_on.timestamp == 1487376000
    assert str(invites[0]) == "Invite to [email protected] (Services) " \
        "with ID: bc30c000-eeee-11e6-8088-111111111111"
    assert 'https://app.pluralsight.com/' in invites[0].generate_url('test')
def _get_session():
    session = Session()
    a = Adapter('tests/fixtures')
    session.adapters = OrderedDict()
    session.mount("http://test.com", a)
    return session
Пример #12
0
from requests_staticmock import (Adapter, BaseMockClass,
                                 mock_session_with_class)
from requests_staticmock.responses import StaticResponseFactory
from six import b
import csv
import os
import pytest
from pluralsight.exceptions import PluralsightApiException
from pluralsight.reports.client import ReportsAPIClient, BASE_URL

TEST_PLAN = 'test-plan'
TEST_API_KEY = 'api_key'
TEST_URL = 'https://app.pluralsight.com'

client = ReportsAPIClient(TEST_PLAN, TEST_API_KEY)
special_adapter = Adapter('tests/fixtures')
client.session.mount('https://app.pluralsight.com', special_adapter)


def test_base_url():
    assert BASE_URL in client.base_url


def test_download_user_report(tmpdir):
    report_name = client.download_user_report(TEST_PLAN, tmpdir)
    with open(os.path.join(tmpdir, report_name), 'r') as f:
        reader = csv.DictReader(f)
        data = [d for d in reader]
        assert data[0]['UserId'] == '12919ae2-c23f-480a-96a8-1534293b0bbe'
        assert data[0]['FirstName'] == 'Sandeep'
        assert data[1]['FirstName'] == 'Imranullah'