# client_test.py
#
# Copyright 2014 BitVault.


from __future__ import print_function

import pytest

import patchboard
import bitvault

from fixtures import (initial_client, users, user, app, apps, wallets,
                      locked_wallet, wallet, accounts, account, addresses,
                      address)
pytest.mark.usefixtures(initial_client, users, user, app, apps, wallets,
                        locked_wallet, wallet, accounts, account, addresses,
                        address)


class TestResourceCreation:

    def test_initial_client(self, initial_client):
        assert initial_client
        # This currently fails because the client() function in __init__.py
        # hides the bitvault.client module
        #assert isinstance(initial_client, bitvault.client.Client)

    def test_users(self, users):
        assert users
        assert isinstance(users, bitvault.collections.Users)

    def test_user(self, user):
        assert user
        assert isinstance(user, bitvault.wrappers.User)

    def test_apps(self, apps):
        assert apps
        assert isinstance(apps, bitvault.collections.Applications)

    def test_app(self, app):
        assert app
        assert isinstance(app, bitvault.wrappers.Application)

    def test_wallets(self, wallets):
        assert wallets
        assert isinstance(wallets, bitvault.collections.Wallets)

    def test_locked_wallet(self, locked_wallet):
        assert locked_wallet
        assert locked_wallet.is_locked()
        assert isinstance(locked_wallet, bitvault.wrappers.Wallet)

    def test_wallet(self, wallet):
        assert wallet
        assert wallet.is_unlocked()
        assert isinstance(wallet, bitvault.wrappers.Wallet)

    def test_accounts(self, accounts):
        assert accounts
        assert isinstance(accounts, bitvault.collections.Accounts)

    def test_account(self, account):
        assert account
        assert isinstance(account, bitvault.wrappers.Account)

    def test_addresses(self, addresses):
        assert addresses
        assert isinstance(addresses, patchboard.resources.Addresses)

    def test_address(self, address):
        assert address
        assert isinstance(address, patchboard.util.SchemaStruct)

@@ -862,25 +862,22 @@
 ert 
-isinstanc
+typ
 e(users
-,
+) ==
  bit
@@ -899,17 +899,16 @@
 ns.Users
-)
 %0A%0A    de
@@ -971,24 +971,21 @@
 ert 
-isinstanc
+typ
 e(user
-,
+) ==
  bit
@@ -1003,17 +1003,16 @@
 ers.User
-)
 %0A%0A    de
@@ -1075,24 +1075,21 @@
 ert 
-isinstanc
+typ
 e(apps
-,
+) ==
  bit
@@ -1118,17 +1118,16 @@
 ications
-)
 %0A%0A    de
@@ -1187,23 +1187,20 @@
 ert 
-isinstanc
+typ
 e(app
-,
+) ==
  bit
@@ -1225,17 +1225,16 @@
 lication
-)
 %0A%0A    de
@@ -1298,33 +1298,27 @@
      assert 
-isinstanc
+typ
 e(wallets, b
@@ -1314,17 +1314,20 @@
 (wallets
-,
+) ==
  bitvaul
@@ -1347,17 +1347,16 @@
 .Wallets
-)
 %0A%0A    de
@@ -1483,25 +1483,19 @@
  assert 
-isinstanc
+typ
 e(locked
@@ -1497,25 +1497,28 @@
 ocked_wallet
-,
+) ==
  bitvault.wr
@@ -1522,33 +1522,32 @@
 .wrappers.Wallet
-)
 %0A%0A    def test_w
@@ -1644,25 +1644,19 @@
 ert 
-isinstanc
+typ
 e(wallet
 , bi
@@ -1651,17 +1651,20 @@
 e(wallet
-,
+) ==
  bitvaul
@@ -1680,17 +1680,16 @@
 s.Wallet
-)
 %0A%0A    de
@@ -1756,33 +1756,27 @@
      assert 
-isinstanc
+typ
 e(accounts, 
@@ -1773,17 +1773,20 @@
 accounts
-,
+) ==
  bitvaul
@@ -1807,17 +1807,16 @@
 Accounts
-)
 %0A%0A    de
@@ -1884,25 +1884,19 @@
  assert 
-isinstanc
+typ
 e(accoun
@@ -1896,17 +1896,20 @@
 (account
-,
+) ==
  bitvaul
@@ -1926,17 +1926,16 @@
 .Account
-)
 %0A%0A    de
@@ -2005,33 +2005,27 @@
      assert 
-isinstanc
+typ
 e(addresses,
@@ -2023,17 +2023,20 @@
 ddresses
-,
+) ==
  patchbo
@@ -2058,17 +2058,16 @@
 ddresses
-)
 %0A%0A    de
@@ -2135,25 +2135,19 @@
  assert 
-isinstanc
+typ
 e(addres
@@ -2147,17 +2147,20 @@
 (address
-,
+) ==
  patchbo
@@ -2180,10 +2180,9 @@
 maStruct
-)
 %0A

Test for exact type