Ejemplo n.º 1
0
    def test_device_retrieval(self):
        device = Device()
        device.operating_system = 'test_device_retrieval_os'
        device.unique_identifier = 'test_device_retrieval'
        device.owner = self.default_user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        new_device = Device.from_auth_token(device.auth_token)
        self.assertEquals(new_device.operating_system, device.operating_system)

        new_device = Device.from_verification_code(device.verification_code)
        self.assertEquals(new_device.operating_system, device.operating_system)
Ejemplo n.º 2
0
    def setUp(self):
        destroy_everything()
        self.default_user = User()
        self.default_user.name = 'Default User'
        self.default_user.email = 'defaultuser@localhost'

        self.default_platform = Platform()
        self.default_platform.name = 'Default Platform'
        self.default_platform.identifier = 'default'
        self.default_platform.owner_email = 'defaultowner@localhost'
        self.default_platform.save()

        self.default_build = Build()
        self.default_build.platform = self.default_platform
        self.default_build.build_number = '1.0.0'
        self.default_build.classification = 'official'
        self.default_build.save()

        self.default_device = Device()
        self.default_device.unique_identifier = 'default_device_unique_identifier'
        self.default_device.owner = self.default_user
        self.default_device.current_build = self.default_build
        self.default_device.platform = self.default_platform
        self.default_device.save()

        self.default_user.devices.append(self.default_device)
        self.default_user.save()
Ejemplo n.º 3
0
 def test_device_smoke_test(self):
     device = Device()
     device.unique_identifier = 'test_device_smoke_test'
     device.owner = self.default_user
     device.current_build = self.default_build
     device.platform = self.default_platform
     device.save()
Ejemplo n.º 4
0
    def test_device_owner_relation(self):
        user = User()
        user.email = 'tesdevicerelations@localhost'
        user.save()

        device = Device()
        device.unique_identifier = 'test_device_relations'
        device.owner = user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        device = Device.from_unique_identifier(device.unique_identifier)
        self.assertEquals(device.owner.email, user.email)
Ejemplo n.º 5
0
def populate():
    for obj in Device.all() + User.all() + Build.all() + Platform.all() + Carrier.all():
        obj.destroy()

    carrier = Carrier()
    carrier.name = 'AT&T'
    carrier.identifier = 'att'
    carrier.save()

    platform = Platform()
    platform.name = 'Android'
    platform.identifier = 'android'
    platform.owner_email = 'android@localhost'
    platform.save()

    platform = Platform()
    platform.name = 'Windows Phone 7'
    platform.identifier = 'wp7'
    platform.owner_email = 'wp7@localhost'
    platform.save()

    platform = Platform()
    platform.name = 'iOS'
    platform.identifier = 'ios'
    platform.owner_email = 'ios@localhost'
    platform.save()

    build = Build()
    build.build_number = '1.0'
    build.platform = platform
    build.classification = 'official'
    build.save()

    beta_build = Build()
    beta_build.build_number = '1.1beta'
    beta_build.platform = platform
    beta_build.classification = 'beta'
    beta_build.save()
    
    user = User()
    user.name = 'User 1'
    user.email = 'user1@localhost'
    user.save()

    device = Device()
    device.owner = user
    device.unique_identifier = str(uuid4())
    device.current_build = build
    device.carrier = carrier
    device.platform = platform
    device.save()

    for i in range(20):
        build = Build()
        build.build_number = '1.1.' + str(i) + 'dev'
        build.platform = platform
        build.classification = 'rolling'
        build.save()

    for i in range(100):
        device = Device()
        device.owner = user
        device.unique_identifier = str(uuid4())
        device.current_build = beta_build
        device.carrier = carrier
        device.platform = platform
        device.save()

    for i in range(100):
        user = User()
        user.email = str(uuid4()) + '@localhost'
        user.save()

        device = Device()
        device.owner = user
        device.unique_identifier = str(uuid4())
        device.current_build = beta_build
        device.carrier = carrier
        device.platform = platform
        device.save()
Ejemplo n.º 6
0
class TestDeviceModel(unittest.TestCase):
    
    def setUp(self):
        destroy_everything()
        self.default_user = User()
        self.default_user.name = 'Default User'
        self.default_user.email = 'defaultuser@localhost'

        self.default_platform = Platform()
        self.default_platform.name = 'Default Platform'
        self.default_platform.identifier = 'default'
        self.default_platform.owner_email = 'defaultowner@localhost'
        self.default_platform.save()

        self.default_build = Build()
        self.default_build.platform = self.default_platform
        self.default_build.build_number = '1.0.0'
        self.default_build.classification = 'official'
        self.default_build.save()

        self.default_device = Device()
        self.default_device.unique_identifier = 'default_device_unique_identifier'
        self.default_device.owner = self.default_user
        self.default_device.current_build = self.default_build
        self.default_device.platform = self.default_platform
        self.default_device.save()

        self.default_user.devices.append(self.default_device)
        self.default_user.save()

    def test_device_smoke_test(self):
        device = Device()
        device.unique_identifier = 'test_device_smoke_test'
        device.owner = self.default_user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

    def test_device_attributes(self):
        device = Device()
        device.unique_identifier = 'test_device_attributes'
        device.model = 'test_device_attributes_model'
        device.operating_system = 'test_device_attributes_os_version'
        device.additional_info = 'test_device_attributes_additional_info'
        device.owner = self.default_user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        new_device = Device.from_unique_identifier(device.unique_identifier)
        self.assertEquals(new_device.model, device.model)
        self.assertEquals(new_device.operating_system, device.operating_system)
        self.assertEquals(new_device.additional_info, device.additional_info)

    def test_device_owner_relation(self):
        user = User()
        user.email = 'tesdevicerelations@localhost'
        user.save()

        device = Device()
        device.unique_identifier = 'test_device_relations'
        device.owner = user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        device = Device.from_unique_identifier(device.unique_identifier)
        self.assertEquals(device.owner.email, user.email)

    def test_device_retrieval(self):
        device = Device()
        device.operating_system = 'test_device_retrieval_os'
        device.unique_identifier = 'test_device_retrieval'
        device.owner = self.default_user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        new_device = Device.from_auth_token(device.auth_token)
        self.assertEquals(new_device.operating_system, device.operating_system)

        new_device = Device.from_verification_code(device.verification_code)
        self.assertEquals(new_device.operating_system, device.operating_system)

    def tearDown(self):
        destroy_everything()
Ejemplo n.º 7
0
def destroy_everything():
    for db_object in Device.all() + User.all() + Build.all() + Platform.all():
        db_object.destroy()
Ejemplo n.º 8
0
    def test_device_attributes(self):
        device = Device()
        device.unique_identifier = 'test_device_attributes'
        device.model = 'test_device_attributes_model'
        device.operating_system = 'test_device_attributes_os_version'
        device.additional_info = 'test_device_attributes_additional_info'
        device.owner = self.default_user
        device.current_build = self.default_build
        device.platform = self.default_platform
        device.save()

        new_device = Device.from_unique_identifier(device.unique_identifier)
        self.assertEquals(new_device.model, device.model)
        self.assertEquals(new_device.operating_system, device.operating_system)
        self.assertEquals(new_device.additional_info, device.additional_info)