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

Commit

Permalink
services: Remove DataCenter model
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldedik committed Aug 20, 2019
1 parent a9ac7fc commit 34e046c
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 304 deletions.
10 changes: 0 additions & 10 deletions test/api/query/snapshots/snap_test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
}
}

snapshots['test_datacenter 1'] = {
'data': {
'node': {
'id': 'RGF0YUNlbnRlcjoxMA==',
'provider': 'kiwi',
'region': 'Oklahoma'
}
}
}

snapshots['test_service 1'] = {
'data': {
'node': {
Expand Down
111 changes: 0 additions & 111 deletions test/api/query/snapshots/snap_test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,117 +103,6 @@
}
}

snapshots['test_with_datacenter 1'] = {
'data': {
'allServices': {
'edges': [
{
'node': {
'dashboardUrl': 'https://dashboard',
'datacenter': {
'id': 'RGF0YUNlbnRlcjoxOA==',
'provider': 'kiwi',
'region': 'Alaska'
},
'docsUrl': 'https://docsurl',
'healthCheckUrl': 'https://healtcheck',
'id': 'U2VydmljZTox',
'impact': 'profit',
'name': 'martinez',
'owner': 'michaelbennett',
'pagerdutyUrl': 'https://pagerduty',
'slackChannel': 'https://slackchannel',
'status': 'fixed'
}
},
{
'node': {
'dashboardUrl': 'https://dashboard',
'datacenter': {
'id': 'RGF0YUNlbnRlcjoxOQ==',
'provider': 'kiwi',
'region': 'Texas'
},
'docsUrl': 'https://docsurl',
'healthCheckUrl': 'https://healtcheck',
'id': 'U2VydmljZToy',
'impact': 'profit',
'name': 'alex',
'owner': 'amstrong',
'pagerdutyUrl': 'https://pagerduty',
'slackChannel': 'https://slackchannel',
'status': 'fixed'
}
},
{
'node': {
'dashboardUrl': 'https://dashboard',
'datacenter': {
'id': 'RGF0YUNlbnRlcjoyMA==',
'provider': 'kiwi',
'region': 'Kansas'
},
'docsUrl': 'https://docsurl',
'healthCheckUrl': 'https://healtcheck',
'id': 'U2VydmljZToz',
'impact': 'profit',
'name': 'artinez',
'owner': 'bennett',
'pagerdutyUrl': 'https://pagerduty',
'slackChannel': 'https://slackchannel',
'status': 'fixed'
}
},
{
'node': {
'dashboardUrl': 'https://dashboard',
'datacenter': {
'id': 'RGF0YUNlbnRlcjoyMQ==',
'provider': 'kiwi',
'region': 'Ohio'
},
'docsUrl': 'https://docsurl',
'healthCheckUrl': 'https://healtcheck',
'id': 'U2VydmljZTo0',
'impact': 'profit',
'name': 'john',
'owner': 'benneto',
'pagerdutyUrl': 'https://pagerduty',
'slackChannel': 'https://slackchannel',
'status': 'fixed'
}
},
{
'node': {
'dashboardUrl': 'https://dashboard',
'datacenter': {
'id': 'RGF0YUNlbnRlcjoyMzQyMw==',
'provider': 'kiwi',
'region': 'Arizona'
},
'docsUrl': 'https://docsurl',
'healthCheckUrl': 'https://healtcheck',
'id': 'U2VydmljZToxMg==',
'impact': 'profit',
'name': 'simmons-mitchell',
'owner': 'dedward',
'pagerdutyUrl': 'https://pagerduty',
'slackChannel': 'https://slackchannel',
'status': 'fixed'
}
}
],
'pageInfo': {
'endCursor': 'NQ==',
'hasNextPage': False,
'hasPreviousPage': False,
'startCursor': 'MQ=='
},
'totalCount': 5
}
}
}

snapshots['test_with_repository 1'] = {
'data': {
'allServices': {
Expand Down
18 changes: 0 additions & 18 deletions test/api/query/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,6 @@ def test_repository(snapshot, call_api, repository_factory):
snapshot.assert_match(response)


def test_datacenter(snapshot, call_api, data_center_factory):
data_center_factory(id=10, provider="kiwi", region="Oklahoma")
id = to_global_id("DataCenter", 10)
query = f"""
query {{
node (id: "{id}") {{
... on DataCenter {{
id
provider
region
}}
}}
}}
"""
response = call_api(query)
snapshot.assert_match(response)


def test_dependency(snapshot, call_api, dependency_factory):
dependency_factory(id=10, name="Python", type="Language")
id = to_global_id("Dependency", 10)
Expand Down
54 changes: 1 addition & 53 deletions test/api/query/test_services.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from zoo.services.models import DataCenter, Service
from zoo.services.models import Service
from zoo.repos.models import Repository

pytestmark = pytest.mark.django_db
Expand All @@ -19,9 +19,6 @@ def generate_services(service_factory):
slack_channel="https://slackchannel",
status="fixed",
health_check_url="https://healtcheck",
datacenter__id=18,
datacenter__region="Alaska",
datacenter__provider="kiwi",
repository__id=78,
repository__remote_id=239,
repository__owner="jasckson",
Expand All @@ -39,9 +36,6 @@ def generate_services(service_factory):
slack_channel="https://slackchannel",
status="fixed",
health_check_url="https://healtcheck",
datacenter__id=19,
datacenter__region="Texas",
datacenter__provider="kiwi",
repository__id=48,
repository__remote_id=99,
repository__owner="colisn",
Expand All @@ -59,9 +53,6 @@ def generate_services(service_factory):
slack_channel="https://slackchannel",
status="fixed",
health_check_url="https://healtcheck",
datacenter__id=20,
datacenter__region="Kansas",
datacenter__provider="kiwi",
repository__id=234,
repository__remote_id=9234,
repository__owner="Daniel",
Expand All @@ -79,9 +70,6 @@ def generate_services(service_factory):
slack_channel="https://slackchannel",
status="fixed",
health_check_url="https://healtcheck",
datacenter__id=21,
datacenter__region="Ohio",
datacenter__provider="kiwi",
repository__id=3434,
repository__remote_id=349,
repository__owner="josh",
Expand All @@ -100,9 +88,6 @@ def generate_services(service_factory):
slack_channel="https://slackchannel",
status="fixed",
health_check_url="https://healtcheck",
datacenter__id=23423,
datacenter__region="Arizona",
datacenter__provider="kiwi",
repository__id=4543,
repository__remote_id=990,
repository__owner="imosley",
Expand Down Expand Up @@ -160,43 +145,6 @@ def test_all(snapshot, call_api, generate_services):
snapshot.assert_match(response)


def test_with_datacenter(snapshot, call_api, generate_services):
query = """
query {
allServices {
totalCount
edges {
node {
id
owner
name
status
impact
slackChannel
pagerdutyUrl
dashboardUrl
docsUrl
healthCheckUrl
datacenter {
id
provider
region
}
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
"""
response = call_api(query)
snapshot.assert_match(response)


def test_with_repository(snapshot, call_api, generate_services):
query = """
query{
Expand Down
2 changes: 0 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
RepositoryFactory,
IssueFactory,
UserFactory,
DataCenterFactory,
ServiceFactory,
DependencyFactory,
DependencyUsageFactory,
Expand All @@ -31,7 +30,6 @@
register(IssueFactory)
register(UserFactory)
register(ServiceFactory)
register(DataCenterFactory)
register(DependencyFactory)
register(DependencyUsageFactory)
register(KindFactory)
Expand Down
11 changes: 1 addition & 10 deletions test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from zoo.auditing.models import Issue
from zoo.auditing.check_discovery import Kind
from zoo.repos.models import Repository
from zoo.services.models import DataCenter, Service
from zoo.services.models import Service
from zoo.analytics.models import Dependency, DependencyUsage, DependencyType
from zoo.analytics.tasks.repo_analyzers import unpack_version

Expand Down Expand Up @@ -36,22 +36,13 @@ class Meta:
)


class DataCenterFactory(DjangoModelFactory):
class Meta:
model = DataCenter

region = Faker("domain_word")
provider = Faker("domain_word")


class ServiceFactory(DjangoModelFactory):
class Meta:
model = Service

owner = Faker("user_name")
name = Faker("domain_word")
impact = choice(["profit", "customers", "customers"])
datacenter = SubFactory(DataCenterFactory)
repository = SubFactory(RepositoryFactory)


Expand Down
29 changes: 6 additions & 23 deletions test/services/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def test_service_form__basic__incorrect():
"name": fake.word(),
"status": "production",
"impact": "profit",
"datacenter": "",
"slack_channel": "dev-null",
"repository": "",
"pagerduty_url": fake.url(),
Expand All @@ -43,26 +42,15 @@ def test_service_form__basic__incorrect():
}


def test_service_form__complete__correct(repository, data_center):
form = ServiceForm(
data={
**service_form_data,
"datacenter": data_center.pk,
"repository": repository.pk,
}
)
def test_service_form__complete__correct(repository):
form = ServiceForm(data={**service_form_data, "repository": repository.pk})

assert form.is_valid()


def test_service_form__complete__incorrect_status(repository, data_center):
def test_service_form__complete__incorrect_status(repository):
form = ServiceForm(
data={
**service_form_data,
"status": "live",
"datacenter": data_center.pk,
"repository": repository.pk,
}
data={**service_form_data, "status": "live", "repository": repository.pk}
)

assert not form.is_valid()
Expand All @@ -71,14 +59,9 @@ def test_service_form__complete__incorrect_status(repository, data_center):
}


def test_service_form__complete__incorrect_dashboard_url(repository, data_center):
def test_service_form__complete__incorrect_dashboard_url(repository):
form = ServiceForm(
data={
**service_form_data,
"dashboard_url": "-",
"datacenter": data_center.pk,
"repository": repository.pk,
}
data={**service_form_data, "dashboard_url": "-", "repository": repository.pk}
)

assert not form.is_valid()
Expand Down
6 changes: 1 addition & 5 deletions zoo/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
from ..analytics.models import Dependency, DependencyType, DependencyUsage
from ..auditing.models import Issue
from ..repos.models import Repository
from ..services.models import DataCenter, Service
from ..services.models import Service
from .paginator import Paginator

DependencyTypeEnum = graphene.Enum.from_enum(DependencyType)


class Query(graphene.ObjectType):
node = relay.Node.Field()
all_datacenters = graphene.List(types.DataCenter)
all_issues = relay.ConnectionField(
types.IssueConnection,
description="List of issues. Returns first 10 nodes if pagination is not specified.",
Expand Down Expand Up @@ -94,9 +93,6 @@ def resolve_all_repositories(self, info, **kwargs):
page_info=page_info, edges=edges, total_count=total
)

def resolve_all_datacenters(self, info):
return DataCenter.objects.all()

def resolve_all_dependencies(self, info, **kwargs):
paginator = Paginator(**kwargs)
filtered_dependencies = Dependency.objects.all()
Expand Down
Loading

0 comments on commit 34e046c

Please sign in to comment.