Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
feat(entity_model): Entity model
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaroslav Sevcik committed Jul 13, 2021
1 parent 2070434 commit 15e7d1a
Show file tree
Hide file tree
Showing 38 changed files with 1,317 additions and 858 deletions.
8 changes: 6 additions & 2 deletions test/api/query/test_service_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ def generate_links(service_factory, link_factory):
)
link_factory(
id=1,
service=service,
content_object=service,
name="Datadog",
url="https://datadog.com",
icon="datadog",
)
link_factory(
id=2, service=service, name="Sentry", url="https://sentry.com", icon="sentry"
id=2,
content_object=service,
name="Sentry",
url="https://sentry.com",
icon="sentry",
)


Expand Down
4 changes: 2 additions & 2 deletions test/api/query/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ def generate_services_with_links(service_factory, link_factory):
)
link_factory(
id=1,
service=service,
content_object=service,
name="Datadog",
url="https://datadog.com",
icon="datadog",
)
link_factory(
id=2,
service=service,
content_object=service,
name="Sentry",
url="https://sentry.com",
icon="Sentry",
Expand Down
12 changes: 10 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import tarfile
from pathlib import Path

import meilisearch
import pytest
import testing.postgresql
from django.conf import settings
from django.db import connections
from environ import Env
from faker import Faker
Expand All @@ -15,12 +13,17 @@
from zoo.auditing.runner import CheckContext
from zoo.factories import (
ApiTokenFactory,
ComponentBaseFactory,
ComponentLibraryFactory,
ComponentServiceFactory,
DependencyFactory,
DependencyUsageFactory,
EnvironmentFactory,
GroupFactory,
InfraNodeFactory,
IssueFactory,
KindFactory,
LibraryFactory,
LinkFactory,
RepositoryFactory,
ServiceFactory,
Expand All @@ -42,6 +45,11 @@
register(DependencyUsageFactory)
register(KindFactory)
register(InfraNodeFactory)
register(ComponentBaseFactory)
register(ComponentLibraryFactory)
register(ComponentServiceFactory)
register(LibraryFactory)
register(GroupFactory)


fake = Faker()
Expand Down
Empty file added test/entities/__init__.py
Empty file.
73 changes: 73 additions & 0 deletions test/entities/test_objects_to_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import pytest
import yaml

from zoo.repos.entities_yaml import generate, validate
from zoo.repos.models import Repository
from zoo.services.models import Environment, Service

pytestmark = pytest.mark.django_db


@pytest.fixture
def generate_base_component(component_base_factory, link_factory, group_factory):
group = group_factory(id=1, product_owner="john", project_owner="doe")
group.save()
component = component_base_factory(
id=1,
name="base",
type="database",
description="This is my fancy component",
kind="component",
owner="platform",
service=None,
library=None,
source__id=1,
source__remote_id=1,
source__owner="jasckson",
source__name="thiwer",
source__url="https://gitlab.com/thiwer/thiwer",
group=group,
)
component.save()
link_factory(
id=1,
name="Datadog",
url="https://dashboard.datadog.com",
icon="poop",
entity=component,
)
link_factory(
id=2,
name="Sentry",
url="https://sentry.skypicker.com",
entity=component,
)


def test_generate_base_component(generate_base_component):
expected = """
- apiVersion: v1alpha1
kind_: component
metadata:
name: base
owner: platform
group:
product_owner: john
project_owner: doe
maintainers: []
description: This is my fancy component
tags: []
links:
- name: Datadog
url: https://dashboard.datadog.com
icon: poop
- name: Sentry
url: https://sentry.skypicker.com
icon: null
spec:
type_: database
"""
repository = Repository.objects.get(pk=1)
content = generate(repository)
assert validate(content)
assert expected.strip() == content.strip()
Loading

0 comments on commit 15e7d1a

Please sign in to comment.