# Path: pyhaystack/client/http/dummy.py
# class DummyHttpServer(object):
# class DummyHttpClient(HTTPClient):
# class DummyHttpClientRequest(object):
#     def __init__(self):
#     def submit_request(
#         self,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def next_request(self):
#     def requests(self):
#     def next_requests(self, count=None):
#     def __init__(self, server, **kwargs):
#     def _request(
#         self,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def __init__(
#         self,
#         rq_id,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def rq_id(self):
#     def method(self):
#     def uri(self):
#     def body(self):
#     def headers(self):
#     def cookies(self):
#     def proxies(self):
#     def auth(self):
#     def timeout(self):
#     def tls_verify(self):
#     def tls_cert(self):
#     def __str__(self):
#     def __hash__(self):
#     def respond(self, status, headers, content, cookies=None):
#     def throw(self, exc_class, *args, **kwargs):
# 
# Path: pyhaystack/client/entity/entity.py
# class Entity(object):
#     """
#     A base class for Project Haystack entities.  This is a base class that is
#     then combined with mix-ins depending on the tags present for the entity and
#     the tagging model in use (by default, we use the "Project Haystack" tagging
#     model, but others such as ISA-95 may exist).
# 
#     This base class just exposes the tags, and if supported by the server, may
#     expose the ability to update those tags.
#     """
# 
#     def __init__(self, session, entity_id):
#         """
#         Initialise a new high-level entity object.
# 
#         :param session: The connection session object.
#         :param entity_id: The entity's fully qualified ID.
#         """
# 
#         self._session = session
#         self._entity_id = entity_id
# 
#         if hasattr(session, "update"):
#             tags = MutableEntityTags(self)
#         else:
#             tags = ReadOnlyEntityTags(self)
# 
#         self._tags = tags
#         self._valid = True
# 
#     @property
#     def id(self):
#         """
#         Return the fully qualified ID of this entity.
#         """
#         return Ref(self._entity_id)
# 
#     @property
#     def dis(self):
#         """
#         Return the description field of the entity.
#         """
#         return self._tags["dis"]
# 
#     @property
#     def tags(self):
#         """
#         Return the tags of this entity.
#         """
#         return self._tags
# 
#     def __repr__(self):
#         """
#         Return a string representation of the entity.
#         """
#         return "<%s: %s>" % (self.id, self.tags)
# 
#     def _update_tags(self, tags):
#         """
#         Update the value of given tags.
#         """
#         self._tags._update_tags(tags)
#         if hasattr(self._session, "_check_entity_type") and (
#             not self._session._check_entity_type(self)
#         ):
#             self._invalidate()
# 
#     def _invalidate(self):
#         """
#         Mark this instance of the entity as invalid, ensure it does not exist
#         in cache.
#         """
#         if self._session._entities.get(self._entity_id) is self:
#             self._session._entities.pop(self._entity_id, None)
#         self._valid = False
# 
# Path: pyhaystack/client/widesky.py
# def _decode_str(s, enc="utf-8"):
#     def __init__(
#         self,
#         uri,
#         username,
#         password,
#         client_id,
#         client_secret,
#         api_dir="api",
#         auth_dir="oauth2/token",
#         impersonate=None,
#         **kwargs
#     ):
#     def is_logged_in(self):
#     def _on_read(self, ids, filter_expr, limit, callback, **kwargs):
#     def _on_http_grid_response(self, response):
#     def _on_authenticate_done(self, operation, **kwargs):
# class WideskyHaystackSession(
#     crud.CRUDOpsMixin,
#     multihis.MultiHisOpsMixin,
#     password.PasswordOpsMixin,
#     HaystackSession,
# ):
#     _AUTH_OPERATION = WideskyAuthenticateOperation
#     _CREATE_ENTITY_OPERATION = CreateEntityOperation
#     _HAS_FEATURES_OPERATION = WideSkyHasFeaturesOperation
#     _PASSWORD_CHANGE_OPERATION = WideSkyPasswordChangeOperation


import pytest
import hszinc
import time
import logging
from pyhaystack.client.http import dummy as dummy_http
from pyhaystack.client.entity.entity import Entity
from pyhaystack.client import widesky
from __future__ import unicode_literals



# For simplicity's sake, we'll just use the WideSky client.
# Pretend we're version 0.0.1.

# hszinc has its own tests, we'll assume they work

# For date/time generation

# Logging setup so we can see what's going on

logging.basicConfig(level=logging.DEBUG)

BASE_URI = "https://myserver/api/"


@pytest.fixture
def server_session():
    """
    Initialise a HaystackSession and dummy HTTP server instance.
    """
    server = dummy_http.DummyHttpServer()
    session = widesky.WideskyHaystackSession(
        uri=BASE_URI,
        username="testuser",
        password="testpassword",
        client_id="testclient",
        client_secret="testclientsecret",

# Path: pyhaystack/client/http/dummy.py
# class DummyHttpServer(object):
# class DummyHttpClient(HTTPClient):
# class DummyHttpClientRequest(object):
#     def __init__(self):
#     def submit_request(
#         self,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def next_request(self):
#     def requests(self):
#     def next_requests(self, count=None):
#     def __init__(self, server, **kwargs):
#     def _request(
#         self,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def __init__(
#         self,
#         rq_id,
#         method,
#         uri,
#         callback,
#         body,
#         headers,
#         cookies,
#         auth,
#         timeout,
#         proxies,
#         tls_verify,
#         tls_cert,
#         accept_status,
#     ):
#     def rq_id(self):
#     def method(self):
#     def uri(self):
#     def body(self):
#     def headers(self):
#     def cookies(self):
#     def proxies(self):
#     def auth(self):
#     def timeout(self):
#     def tls_verify(self):
#     def tls_cert(self):
#     def __str__(self):
#     def __hash__(self):
#     def respond(self, status, headers, content, cookies=None):
#     def throw(self, exc_class, *args, **kwargs):
# 
# Path: pyhaystack/client/entity/entity.py
# class Entity(object):
#     """
#     A base class for Project Haystack entities.  This is a base class that is
#     then combined with mix-ins depending on the tags present for the entity and
#     the tagging model in use (by default, we use the "Project Haystack" tagging
#     model, but others such as ISA-95 may exist).
# 
#     This base class just exposes the tags, and if supported by the server, may
#     expose the ability to update those tags.
#     """
# 
#     def __init__(self, session, entity_id):
#         """
#         Initialise a new high-level entity object.
# 
#         :param session: The connection session object.
#         :param entity_id: The entity's fully qualified ID.
#         """
# 
#         self._session = session
#         self._entity_id = entity_id
# 
#         if hasattr(session, "update"):
#             tags = MutableEntityTags(self)
#         else:
#             tags = ReadOnlyEntityTags(self)
# 
#         self._tags = tags
#         self._valid = True
# 
#     @property
#     def id(self):
#         """
#         Return the fully qualified ID of this entity.
#         """
#         return Ref(self._entity_id)
# 
#     @property
#     def dis(self):
#         """
#         Return the description field of the entity.
#         """
#         return self._tags["dis"]
# 
#     @property
#     def tags(self):
#         """
#         Return the tags of this entity.
#         """
#         return self._tags
# 
#     def __repr__(self):
#         """
#         Return a string representation of the entity.
#         """
#         return "<%s: %s>" % (self.id, self.tags)
# 
#     def _update_tags(self, tags):
#         """
#         Update the value of given tags.
#         """
#         self._tags._update_tags(tags)
#         if hasattr(self._session, "_check_entity_type") and (
#             not self._session._check_entity_type(self)
#         ):
#             self._invalidate()
# 
#     def _invalidate(self):
#         """
#         Mark this instance of the entity as invalid, ensure it does not exist
#         in cache.
#         """
#         if self._session._entities.get(self._entity_id) is self:
#             self._session._entities.pop(self._entity_id, None)
#         self._valid = False
# 
# Path: pyhaystack/client/widesky.py
# def _decode_str(s, enc="utf-8"):
#     def __init__(
#         self,
#         uri,
#         username,
#         password,
#         client_id,
#         client_secret,
#         api_dir="api",
#         auth_dir="oauth2/token",
#         impersonate=None,
#         **kwargs
#     ):
#     def is_logged_in(self):
#     def _on_read(self, ids, filter_expr, limit, callback, **kwargs):
#     def _on_http_grid_response(self, response):
#     def _on_authenticate_done(self, operation, **kwargs):
# class WideskyHaystackSession(
#     crud.CRUDOpsMixin,
#     multihis.MultiHisOpsMixin,
#     password.PasswordOpsMixin,
#     HaystackSession,
# ):
#     _AUTH_OPERATION = WideskyAuthenticateOperation
#     _CREATE_ENTITY_OPERATION = CreateEntityOperation
#     _HAS_FEATURES_OPERATION = WideSkyHasFeaturesOperation
#     _PASSWORD_CHANGE_OPERATION = WideSkyPasswordChangeOperation


# Path: tests/client/test_entity.py
import pytest
import hszinc
import time
import logging
from pyhaystack.client.http import dummy as dummy_http
from pyhaystack.client.entity.entity import Entity
from pyhaystack.client import widesky

from __future__ import unicode_literals



# For simplicity's sake, we'll just use the WideSky client.
# Pretend we're version 0.0.1.

# hszinc has its own tests, we'll assume they work

# For date/time generation

# Logging setup so we can see what's going on

logging.basicConfig(level=logging.DEBUG)

BASE_URI = "https://myserver/api/"


@pytest.fixture
def server_session():
    """
    Initialise a HaystackSession and dummy HTTP server instance.
    """
    server = dummy_http.DummyHttpServer()
    session = widesky.WideskyHaystackSession(
        uri=BASE_URI,
        username="testuser",
        password="testpassword",
        client_id="testclient",
        client_secret="testclientsecret",

        http_client=dummy_http.DummyHttpClient,