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

Commit

Permalink
Merge pull request #592 from cdosborn/deploy-image-scripts
Browse files Browse the repository at this point in the history
Fix image scripts not being included in user deploy
  • Loading branch information
cdosborn authored Mar 6, 2018
2 parents fc978da + 46666ed commit 42ef4f0
Show file tree
Hide file tree
Showing 20 changed files with 145 additions and 256 deletions.
4 changes: 3 additions & 1 deletion api/tests/factories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from .quota_factory import QuotaFactory
from .allocation_factory import AllocationFactory
from .provider_type_factory import ProviderTypeFactory
from .provider_machine_factory import ProviderMachineFactory, InstanceSourceFactory
from .provider_machine_factory import ProviderMachineFactory
from .platform_type_factory import PlatformTypeFactory
from .size_factory import SizeFactory
from .allocation_source_factory import AllocationSourceFactory, UserAllocationSourceFactory
from .boot_script_factory import BootScriptRawTextFactory, BootScriptURLFactory
from .instance_source_factory import InstanceSourceFactory
21 changes: 21 additions & 0 deletions api/tests/factories/boot_script_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import factory
from factory import fuzzy
from api.tests.factories import UserFactory, InstanceFactory
from core.models import BootScript, ScriptType


class BootScriptFactory(factory.DjangoModelFactory):

class Meta:
model = BootScript

title = fuzzy.FuzzyText(prefix="bootscript-title-")
created_by = factory.SubFactory(UserFactory)


class BootScriptRawTextFactory(BootScriptFactory):
script_type = factory.LazyAttribute(lambda _: ScriptType.objects.get_or_create(name='Raw Text')[0])


class BootScriptURLFactory(BootScriptFactory):
script_type = factory.LazyAttribute(lambda _: ScriptType.objects.get_or_create(name='URL')[0])
3 changes: 3 additions & 0 deletions api/tests/factories/group_factory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import factory
from factory import fuzzy
from core.models import Group


class GroupFactory(factory.DjangoModelFactory):

class Meta:
model = Group

name = fuzzy.FuzzyText(prefix="name-")
4 changes: 4 additions & 0 deletions api/tests/factories/identity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ def create_identity(created_by, group=None, provider=None, quota=None):

class Meta:
model = Identity

created_by = factory.SubFactory(UserFactory)
provider = factory.SubFactory(ProviderFactory)
quota = factory.SubFactory(QuotaFactory)
3 changes: 3 additions & 0 deletions api/tests/factories/image_factory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import factory
from core.models import Application as Image
from .user_factory import UserFactory


class ImageFactory(factory.DjangoModelFactory):

class Meta:
model = Image

created_by = factory.SubFactory(UserFactory)
16 changes: 16 additions & 0 deletions api/tests/factories/instance_factory.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import factory
from core.models import Instance
from django.utils import timezone
from .user_factory import UserFactory
from .project_factory import ProjectFactory
from .instance_source_factory import InstanceSourceFactory
from .provider_machine_factory import ProviderMachineFactory
from .identity_factory import IdentityFactory



class InstanceFactory(factory.DjangoModelFactory):

class Meta:
model = Instance
exclude = ('provider_machine',)

provider_machine = factory.SubFactory(ProviderMachineFactory)
start_date = factory.LazyFunction(timezone.now)
project = factory.SubFactory(ProjectFactory)
source = factory.SelfAttribute('provider_machine.instance_source')
created_by = factory.SubFactory(UserFactory)
created_by_identity = factory.LazyAttribute(
lambda model: IdentityFactory(created_by=model.created_by))
12 changes: 12 additions & 0 deletions api/tests/factories/instance_source_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import factory
import uuid
from core.models import ProviderMachine, InstanceSource
from .provider_factory import ProviderFactory

class InstanceSourceFactory(factory.DjangoModelFactory):

class Meta:
model = InstanceSource

identifier = factory.Sequence(lambda n: uuid.uuid4())
provider = factory.SubFactory(ProviderFactory)
10 changes: 8 additions & 2 deletions api/tests/factories/project_factory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import factory
from factory import fuzzy
from core.models import Project

from .group_factory import GroupFactory
from .user_factory import UserFactory


class ProjectFactory(factory.DjangoModelFactory):

class Meta:
model = Project

name = 'project name'
description = 'project description'
name = fuzzy.FuzzyText(prefix="name-")
description = fuzzy.FuzzyText(prefix="description-")
created_by = factory.SubFactory(UserFactory)
owner = factory.SubFactory(GroupFactory)
13 changes: 6 additions & 7 deletions api/tests/factories/provider_machine_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from core.models import ProviderMachine, InstanceSource
from .version_factory import ApplicationVersionFactory
from .image_factory import ImageFactory
from .provider_factory import ProviderFactory
from .instance_source_factory import InstanceSourceFactory
from .version_factory import ApplicationVersionFactory


class ProviderMachineFactory(factory.DjangoModelFactory):
Expand Down Expand Up @@ -32,10 +35,6 @@ def create_provider_machine(user, identity, application=None, version=None):
class Meta:
model = ProviderMachine


class InstanceSourceFactory(factory.DjangoModelFactory):

class Meta:
model = InstanceSource

identifier = factory.Sequence(lambda n: uuid.uuid4())
# Field occurs on super class of ProviderMachine
instance_source = factory.SubFactory(InstanceSourceFactory)
application_version = factory.SubFactory(ApplicationVersionFactory)
5 changes: 5 additions & 0 deletions api/tests/factories/version_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import factory
from core.models import ApplicationVersion
from .image_factory import ImageFactory
from .user_factory import UserFactory
from .identity_factory import IdentityFactory


class ApplicationVersionFactory(factory.DjangoModelFactory):
Expand All @@ -21,3 +23,6 @@ class Meta:
model = ApplicationVersion

application = factory.SubFactory(ImageFactory)
created_by = factory.SubFactory(UserFactory) #factory.SelfAttribute("created_by_identity.created_by")
created_by_identity = factory.LazyAttribute(
lambda model: IdentityFactory(created_by=model.created_by))
1 change: 1 addition & 0 deletions api/tests/v2/test_image_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def test_user_sees_no_statistics(self):
response = client.get(url)
self.assertEquals(response.status_code, 404)

@skip("Test is non deterministic and yields different results based on its redis cache")
def test_staff_sees_accurate_application_statistics(self):
"""Given the setUp above, 1/4 instances are active."""
client = APIClient()
Expand Down
8 changes: 0 additions & 8 deletions core/factories/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions core/factories/account.py

This file was deleted.

16 changes: 0 additions & 16 deletions core/factories/group.py

This file was deleted.

22 changes: 0 additions & 22 deletions core/factories/identity.py

This file was deleted.

81 changes: 0 additions & 81 deletions core/factories/provider.py

This file was deleted.

24 changes: 0 additions & 24 deletions core/factories/user.py

This file was deleted.

Loading

0 comments on commit 42ef4f0

Please sign in to comment.