# encoding: utf8
from __future__ import unicode_literals
import pytest
from flexmock import flexmock
from hypothesis import given, strategies
import abc

from ...._classes import model as base
from ....ops import NumpyOps


@pytest.fixture
def model_with_no_args():
    model = base.Model()
    return model


def test_Model_defaults_to_name_model(model_with_no_args):
    assert model_with_no_args.name == 'model'


def test_changing_instance_name_doesnt_change_class_name():
    model = base.Model()
    assert model.name != 'changed'
    model.name = 'changed'
    model2 = base.Model()
    assert model2.name != 'changed'


def test_changing_class_name_doesnt_change_default_instance_name():
    model = base.Model()
    assert model.name != 'changed'
    base.Model.name = 'changed'
    assert model.name != 'changed'
    # Reset state
    base.Model.name = 'model'

def test_changing_class_name_doesnt_changes_nondefault_instance_name():
    model = base.Model(name='nondefault')
    assert model.name == 'nondefault'
    base.Model.name = 'changed'
    assert model.name == 'nondefault'


def test_Model_defaults_to_cpu(model_with_no_args):
    assert isinstance(model_with_no_args.ops, NumpyOps)


def test_models_get_different_ids(model_with_no_args):
    model1 = base.Model()
    model2 = base.Model()
    assert model1.id != model2.id

@@ -1340,8 +1340,884 @@
 del2.id%0A
+%0Adef test_init_assigns_privates():%0A    model = base.Model()%0A    assert model._mem is None%0A    assert model._layers == %5B%5D%0A    assert model._operators == %7B%7D%0A%0A%0Adef test_init_installs_via_descriptions():%0A    def mock_install(attr, self):%0A        setattr(self, attr, 'model=' + self.name)%0A    base.Model.descriptions = %5B(%22myattr%22, mock_install)%5D%0A    model = base.Model(name='model1')%0A    assert model.myattr == 'model=%25s' %25 'model1'%0A    model2 = base.Model(name='model2')%0A    assert model2.myattr == 'model=%25s' %25 'model2'%0A%0A%0Adef test_init_calls_hooks():%0A    def mock_init_hook(self, *args, **kwargs):%0A        setattr(self, 'hooked', (args, kwargs))%0A    base.Model.on_init_hooks = %5Bmock_init_hook%5D%0A    model = base.Model(0, 1, 2)%0A    assert model.hooked == ((0, 1, 2), %7B%7D)%0A    model2 = base.Model(value='something')%0A    assert model2.hooked == (tuple(), %7B'value': 'something'%7D)%0A%0A   %0A

Update init tests