예제 #1
0
    def default_command(self):
        default_command = Command(name="name", description="description")
        default_command.save = Mock()
        default_command.validate = Mock()
        default_command.delete = Mock()

        return default_command
예제 #2
0
def system_not_permitted(garden):
    system = System(
        name="system_not_permitted",
        version="0.0.1",
        namespace=garden.name,
        commands=[Command(name="command_not_permitted")],
    ).save()

    yield system
    system.delete()
예제 #3
0
def system_permitted(garden):
    system = System(
        name="permitted_system",
        version="0.0.1",
        namespace=garden.name,
        commands=[Command(name="icandoit")],
    ).save()

    yield system
    system.delete()
예제 #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",
        )
예제 #5
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),
        )
예제 #6
0
    def test_clean_fail_duplicate_parameter_keys(self):
        parameter = Parameter(key="foo", optional=False)
        command = Command(name="foo", parameters=[parameter, parameter])

        with pytest.raises(ModelValidationError):
            command.clean()
예제 #7
0
 def test_clean_empty_name(self, params):
     with pytest.raises(ModelValidationError):
         Command(**params).clean()
예제 #8
0
 def test_clean(self):
     Command(name="foo", parameters=[Parameter(key="foo",
                                               optional=False)]).clean()
예제 #9
0
 def test_repr(self):
     c = Command(name="foo", description="bar", parameters=[])
     assert repr(c) == "<Command: foo>"
예제 #10
0
 def test_str(self):
     assert str(Command(name="foo", parameters=[])) == "foo"