示例#1
0
    def default_instance(self):
        default_instance = Instance(name="default")
        default_instance.save = Mock()
        default_instance.validate = Mock()
        default_instance.delete = Mock()

        return default_instance
示例#2
0
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()
示例#3
0
    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",
        )
示例#4
0
    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),
        )
示例#5
0
 def test_clean_bad_status(self):
     with pytest.raises(ModelValidationError):
         Instance(status="BAD").clean()
示例#6
0
 def test_repr(self):
     instance = Instance(name="name", status="RUNNING")
     assert "name" in repr(instance)
     assert "RUNNING" in repr(instance)
示例#7
0
 def test_str(self):
     assert str(Instance(name="name")) == "name"
示例#8
0
 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()