def default_instance(self): default_instance = Instance(name="default") default_instance.save = Mock() default_instance.validate = Mock() default_instance.delete = Mock() return default_instance
def system(garden): instance = Instance(name="instance") system = System( name="system", version="1.0.0", namespace=garden.name, instances=[instance], ).save() yield system system.delete()
def setUp(self): self.app = brew_view.app.test_client() self.default_instance = Instance(name="default", status="RUNNING") self.default_command = Command(id="54ac18f778c4b57e963f3c18", name="command", description="foo") self.default_system = System( id="54ac18f778c4b57e963f3c18", name="default_system", version="1.0.0", instances=[self.default_instance], commands=[self.default_command], max_instances="1", )
def setUp(self): self.app = brew_view.app.test_client() self.default_instance = Instance(name="default", status="RUNNING") self.default_command = Command(id="54ac18f778c4b57e963f3c18", name="command", description="foo") self.default_system = System( id="54ac18f778c4b57e963f3c18", name="default_system", version="1.0.0", instances=[self.default_instance], commands=[self.default_command], max_instances="1", ) self.client_mock = Mock(name="client_mock") self.fake_context = MagicMock( __enter__=Mock(return_value=self.client_mock), __exit__=Mock(return_value=False), )
def test_clean_bad_status(self): with pytest.raises(ModelValidationError): Instance(status="BAD").clean()
def test_repr(self): instance = Instance(name="name", status="RUNNING") assert "name" in repr(instance) assert "RUNNING" in repr(instance)
def test_str(self): assert str(Instance(name="name")) == "name"
def test_clean_fail_duplicate_instance_names(self, default_system): default_system.max_instances = 2 default_system.instances.append(Instance(name="default")) with pytest.raises(ModelValidationError): default_system.clean()