Пример #1
0
def garden_not_permitted():
    garden = Garden(
        name="notpermitted", connection_type="HTTP", namespaces=["notpermitted"]
    ).save()

    yield garden
    garden.delete()
Пример #2
0
def garden_permitted():
    garden = Garden(
        name="somegarden", connection_type="LOCAL", namespaces=["somegarden"]
    ).save()

    yield garden
    garden.delete()
Пример #3
0
    def child_garden(self, child_system_v1):
        garden = Garden(name="child_garden",
                        connection_type="http",
                        systems=[child_system_v1]).save()

        yield garden

        garden.delete()
Пример #4
0
def data_cleanup():
    """Cleanup all data between test modules to ensure each one is independent"""
    yield
    Event.drop_collection()
    File.drop_collection()
    Garden.drop_collection()
    Job.drop_collection()
    RawFile.drop_collection()
    Request.drop_collection()
    RemoteUser.drop_collection()
    Role.drop_collection()
    System.drop_collection()
    User.drop_collection()
    UserToken.drop_collection()
Пример #5
0
    def setUp(self):
        self.app = brew_view.app.test_client()

        self.default_garden = Garden(
            garden_name="default",
            status="RUNNING",
            connection_type="http",
            connection_params={"host": "local"},
        )
Пример #6
0
    def test_ensure_local_garden_updates_garden_from_config(self, monkeypatch):
        """ensure_local_garden should update the name of an existing Garden entry in the
        database with a connection type of LOCAL"""
        monkeypatch.setattr(config, "get", self.config_get)

        Garden(name="thisshouldchange", connection_type="LOCAL").save()
        ensure_local_garden()
        garden = Garden.objects.get(connection_type="LOCAL")

        assert garden.name == config.get("garden.name")
Пример #7
0
    def test_child_garden_system_id_update(self, child_garden,
                                           child_system_v1_diff_id):
        """If the systems of a child garden are updated such that the names, namespaces
        and versions remain constant, but the IDs are different, the original systms
        are removed and replaced with the new systems when the garden is saved."""
        orig_system_ids = set(
            map(lambda x: str(getattr(x, "id")),
                child_garden.systems)  # noqa: B009
        )
        new_system_id = str(child_system_v1_diff_id.id)

        assert new_system_id not in orig_system_ids

        child_garden.systems = [child_system_v1_diff_id]
        child_garden.deep_save()
        db_garden = Garden.objects().first()

        new_system_ids = set(
            map(lambda x: str(getattr(x, "id")),
                db_garden.systems)  # noqa: B009
        )

        assert new_system_id in new_system_ids
        assert orig_system_ids.intersection(new_system_ids) == set()
Пример #8
0
    def test_child_garden_system_attrib_update(self, child_garden,
                                               child_system_v2):
        """If the systems of a child garden are updated such that their names,
        namespaces, or versions are changed, the original systems are removed and
        replaced with the new systems when the garden is saved."""
        orig_system_ids = set(
            map(lambda x: str(getattr(x, "id")),
                child_garden.systems)  # noqa: B009
        )
        orig_system_versions = set(
            map(
                lambda x: str(getattr(x, "version")),
                child_garden.systems  # noqa: B009
            ))

        assert (self.v1_str in orig_system_versions
                and self.v2_str not in orig_system_versions)

        child_garden.systems = [child_system_v2]
        child_garden.deep_save()

        # we check that the garden written to the DB has the correct systems
        db_garden = Garden.objects().first()

        new_system_ids = set(
            map(lambda x: str(getattr(x, "id")),
                db_garden.systems)  # noqa: B009
        )
        new_system_versions = set(
            map(lambda x: str(getattr(x, "version")),
                db_garden.systems)  # noqa: B009
        )

        assert (self.v1_str not in new_system_versions
                and self.v2_str in new_system_versions)
        assert new_system_ids.intersection(orig_system_ids) == set()
Пример #9
0
def drop():
    Garden.drop_collection()
    Role.drop_collection()
    System.drop_collection()
    User.drop_collection()
Пример #10
0
def test_garden(role_assignment_for_garden_scope):
    garden = Garden(**role_assignment_for_garden_scope.domain.identifiers).save()

    yield garden
    garden.delete()
Пример #11
0
def garden_not_permitted():
    garden = Garden(name="remotegarden", connection_type="HTTP").save()

    yield garden
    garden.delete()
Пример #12
0
def garden_permitted():
    garden = Garden(name="garden_permitted", connection_type="LOCAL").save()

    yield garden
    garden.delete()
Пример #13
0
    def gardens(self):
        garden1 = Garden(name="garden1",
                         connection_type="HTTP",
                         status="RUNNING").save()
        garden2 = Garden(name="garden2",
                         connection_type="HTTP",
                         status="RUNNING").save()
        garden3 = Garden(name="garden2",
                         connection_type="HTTP",
                         status="STOPPED").save()

        yield [garden1, garden2, garden3]
        garden1.delete()
        garden2.delete()
        garden3.delete()
Пример #14
0
def remote_garden():
    garden = Garden(name="remotegarden", connection_type="HTTP").save()

    yield garden
    garden.delete()
Пример #15
0
    def local_garden(self, mongo_conn):
        garden = Garden(name=self.garden_name, connection_type="LOCAL").save()

        yield garden

        garden.delete()
Пример #16
0
 def setup_class(cls):
     connect("beer_garden", host="mongomock://localhost")
     Garden.drop_collection()
     Garden.ensure_indexes()
Пример #17
0
def drop():
    yield
    Garden.drop_collection()
    System.drop_collection()
Пример #18
0
def garden_cleanup():
    yield
    Garden.drop_collection()
Пример #19
0
 def test_garden_names_are_required_to_be_unique(self, local_garden):
     """Attempting to create a garden that shares a name with an existing garden
     should raise an exception"""
     with pytest.raises(NotUniqueError):
         Garden(name=local_garden.name, connection_type="HTTP").save()
Пример #20
0
 def test_only_one_local_garden_may_exist(self, local_garden):
     """Attempting to create more than one garden with connection_type of LOCAL
     should raise an exception"""
     with pytest.raises(NotUniqueError):
         Garden(name=f"not{local_garden.name}",
                connection_type="LOCAL").save()
Пример #21
0
def garden():
    garden = Garden(name="somegarden", connection_type="LOCAL").save()

    yield garden
    garden.delete()
Пример #22
0
    def test_user_synced_with_garden_returns_true_for_no_relevant_assignments(
            self):
        user = User(username="******")
        garden = Garden(name="garden")

        assert user_synced_with_garden(user, garden) is True