Exemplo n.º 1
0
    def test_updatecheck_positive_critical_on_other_channel(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        channel2 = ChannelFactory.create(name='alpha')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel2,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        Action.objects.create(
            version=last_version,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=last_version,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_positive)
Exemplo n.º 2
0
    def test_updatecheck_positive_critical_on_other_channel(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        channel2 = ChannelFactory.create(name='alpha')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel2,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        Action.objects.create(
            version=last_version,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=last_version,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_positive)
Exemplo n.º 3
0
    def test_data(self):
        app = ApplicationFactory.create(id='{430FD4D0-B729-4F61-AA34-91526481799D}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Data.objects.create(
            app=app,
            name=NAME_DATA_DICT_CHOICES['install'],
            index='verboselogging',
            value='app-specific values here')

        Data.objects.create(
            app=app,
            name=NAME_DATA_DICT_CHOICES['untrusted'])

        response = self.client.post(reverse('update'),
                                    fixtures.request_data, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_data)
Exemplo n.º 4
0
    def test_data(self):
        app = ApplicationFactory.create(
            id='{430FD4D0-B729-4F61-AA34-91526481799D}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(app=app,
                                    platform=platform,
                                    channel=channel,
                                    version='13.0.782.112',
                                    file=SimpleUploadedFile(
                                        './chrome_installer.exe',
                                        b'_' * 23963192),
                                    file_size=23963192)
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Data.objects.create(app=app,
                            name=NAME_DATA_DICT_CHOICES['install'],
                            index='verboselogging',
                            value='app-specific values here')

        Data.objects.create(app=app, name=NAME_DATA_DICT_CHOICES['untrusted'])

        response = self.client.post(reverse('update'),
                                    fixtures.request_data,
                                    content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_data)
Exemplo n.º 5
0
    def test_sparkle(self):
        app = ApplicationFactory.create(
            id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        channel = ChannelFactory.create(name='stable')
        obj = SparkleVersionFactory.create(app=app,
                                           channel=channel,
                                           version='782.112',
                                           short_version='13.0.782.112',
                                           minimum_system_version='10.14.4',
                                           file=SimpleUploadedFile(
                                               './chrome.dmg',
                                               b'_' * 23963192),
                                           file_size=23963192)
        obj.save()

        response = self.client.get(reverse('sparkle_appcast',
                                           args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(
            response.content,
            fixtures.response_sparkle_with_minimum_system_version)
Exemplo n.º 6
0
    def test_sparkle_critical(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        channel = ChannelFactory.create(name='stable')
        first_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.110',
            short_version='13.0.782.110',
            file=SimpleUploadedFile('./chrome1.dmg', b'_' * 23963192),
            file_size=23963192)
        first_version.save()

        first_crit_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.111',
            short_version='13.0.782.111',
            is_critical=True,
            file=SimpleUploadedFile('./chrome2.dmg', b'_' * 23963192),
            file_size=23963192)
        first_crit_version.save()

        last_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.112',
            short_version='13.0.782.112',
            file=SimpleUploadedFile('./chrome3.dmg', b'_' * 23963192),
            file_size=23963192)
        last_version.save()

        second_crit_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.113',
            short_version='13.0.782.113',
            is_critical=True,
            file=SimpleUploadedFile('./chrome4.dmg', b'_' * 23963192),
            file_size=23963192)
        second_crit_version.save()

        response = self.client.get("%s?appVersionShort=13.0.782.110" % reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.first_crit_response_sparkle)

        response = self.client.get("%s?appVersionShort=13.0.782.111" % reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.second_crit_response_sparkle)
Exemplo n.º 7
0
    def test_sparkle_critical(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        channel = ChannelFactory.create(name='stable')
        first_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.110',
            short_version='13.0.782.110',
            file=SimpleUploadedFile('./chrome1.dmg', b'_' * 23963192),
            file_size=23963192)
        first_version.save()

        first_crit_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.111',
            short_version='13.0.782.111',
            is_critical=True,
            file=SimpleUploadedFile('./chrome2.dmg', b'_' * 23963192),
            file_size=23963192)
        first_crit_version.save()

        last_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.112',
            short_version='13.0.782.112',
            file=SimpleUploadedFile('./chrome3.dmg', b'_' * 23963192),
            file_size=23963192)
        last_version.save()

        second_crit_version = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.113',
            short_version='13.0.782.113',
            is_critical=True,
            file=SimpleUploadedFile('./chrome4.dmg', b'_' * 23963192),
            file_size=23963192)
        second_crit_version.save()

        response = self.client.get("%s?appVersionShort=13.0.782.110" % reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.first_crit_response_sparkle)

        response = self.client.get("%s?appVersionShort=13.0.782.111" % reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.second_crit_response_sparkle)
Exemplo n.º 8
0
    def test_userid_counting(self):
        now = datetime.utcnow()
        userid = '{D0BBD725-742D-44ae-8D46-0231E881D58E}'
        user_id = get_id(userid)
        appid1 = '{430FD4D0-B729-4F61-AA34-91526481799D}'
        appid2 = '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}'

        request_events = DayEvents('request', now.year, now.month, now.day)
        app1_events = DayEvents('request:%s' % appid1, now.year, now.month,
                                now.day)
        app2_events = DayEvents('request:%s' % appid2, now.year, now.month,
                                now.day)

        self.assertEqual(len(request_events), 0)
        self.assertEqual(len(app1_events), 0)
        self.assertEqual(len(app2_events), 0)

        app = ApplicationFactory.create(
            id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(app=app,
                                    platform=platform,
                                    channel=channel,
                                    version='13.0.782.112',
                                    file=SimpleUploadedFile(
                                        './chrome_installer.exe',
                                        b'_' * 23963192))
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Action.objects.create(version=obj,
                              arguments='--do-not-launch-chrome',
                              event=EVENT_DICT_CHOICES['install'],
                              run='chrome_installer.exe')

        Action.objects.create(version=obj,
                              event=EVENT_DICT_CHOICES['postinstall'],
                              other=dict(
                                  version='13.0.782.112',
                                  onsuccess='exitsilentlyonlaunchcmd',
                              ))

        self.client.post(reverse('update'),
                         fixtures.request_update_check,
                         content_type='text/xml')

        self.assertEqual(len(request_events), 1)
        self.assertEqual(len(app1_events), 1)
        self.assertEqual(len(app2_events), 1)
        self.assertTrue(user_id in request_events)
        self.assertTrue(user_id in app1_events)
        self.assertTrue(user_id in app2_events)
Exemplo n.º 9
0
 def test_create(self):
     data = dict(
         app=ApplicationFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
     )
     response = self.client.post(self.url, data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     version = SparkleVersion.objects.get(id=response.data['id'])
     self.assertEqual(response.data, self.serializer(version).data)
     self.assertEqual(version.file_size, len(b'content'))
Exemplo n.º 10
0
    def test_userid_counting(self):
        now = datetime.utcnow()
        userid = '{D0BBD725-742D-44ae-8D46-0231E881D58E}'
        user_id = get_id(userid)
        appid1 = '{430FD4D0-B729-4F61-AA34-91526481799D}'
        appid2 = '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}'

        request_events = DayEvents('request', now.year, now.month, now.day)
        app1_events = DayEvents('request:%s' % appid1, now.year, now.month, now.day)
        app2_events = DayEvents('request:%s' % appid2, now.year, now.month, now.day)

        self.assertEqual(len(request_events), 0)
        self.assertEqual(len(app1_events), 0)
        self.assertEqual(len(app2_events), 0)


        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192))
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Action.objects.create(
            version=obj,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=obj,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        self.client.post(reverse('update'),
                         fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(len(request_events), 1)
        self.assertEqual(len(app1_events), 1)
        self.assertEqual(len(app2_events), 1)
        self.assertTrue(user_id in request_events)
        self.assertTrue(user_id in app1_events)
        self.assertTrue(user_id in app2_events)
Exemplo n.º 11
0
    def test_updatecheck_positive_critical(self):
        app = ApplicationFactory.create(
            id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe',
                                    b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe',
                                    b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(app=app,
                                             platform=platform,
                                             channel=channel,
                                             version='13.0.782.112',
                                             file=SimpleUploadedFile(
                                                 './chrome_installer.exe',
                                                 b'_' * 23963192),
                                             file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check,
                                    content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(
            response.content,
            fixtures.response_update_check_postitive_critical)
Exemplo n.º 12
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         channel=ChannelFactory.create().id,
         version='3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = SparkleVersion.objects.get(id=obj_id)
     self.assertEqual(version.version, '3.4')
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(version='3.5'))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = SparkleVersion.objects.get(id=obj_id)
     self.assertEqual(version.version, '3.5')
Exemplo n.º 13
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         channel=ChannelFactory.create().id,
         version='3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = SparkleVersion.objects.get(id=obj_id)
     self.assertEqual(version.version, '3.4')
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(version='3.5'))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = SparkleVersion.objects.get(id=obj_id)
     self.assertEqual(version.version, '3.5')
Exemplo n.º 14
0
    def test_updatecheck_positive_critical(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_postitive_critical)
Exemplo n.º 15
0
    def test_sparkle(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        channel = ChannelFactory.create(name='stable')
        obj = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.112',
            short_version='13.0.782.112',
            file=SimpleUploadedFile('./chrome.dmg', b'_' * 23963192),
            file_size=23963192)
        obj.save()

        response = self.client.get(reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_sparkle)
Exemplo n.º 16
0
    def test_sparkle_with_dsa_signature(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C9C}', name='chrome_dsa')
        channel = ChannelFactory.create(name='stable')
        obj = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.112',
            short_version='13.0.782.112',
            dsa_signature='MCwCFCdoW13VBGJWIfIklKxQVyetgxE7AhQTVuY9uQT0KOV1UEk21epBsGZMPg==',
            file=SimpleUploadedFile('./chrome.dmg', b'_' * 23963192),
            file_size=23963192)
        obj.save()

        response = self.client.get(reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(fixtures.response_sparkle_with_dsa,
                                        response.content)
Exemplo n.º 17
0
    def test_sparkle_with_dsa_signature(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C9C}', name='chrome_dsa')
        channel = ChannelFactory.create(name='stable')
        obj = SparkleVersionFactory.create(
            app=app,
            channel=channel,
            version='782.112',
            short_version='13.0.782.112',
            dsa_signature='MCwCFCdoW13VBGJWIfIklKxQVyetgxE7AhQTVuY9uQT0KOV1UEk21epBsGZMPg==',
            file=SimpleUploadedFile('./chrome.dmg', b'_' * 23963192),
            file_size=23963192)
        obj.save()

        response = self.client.get(reverse('sparkle_appcast', args=(app.name, channel.name)),
                                   HTTP_HOST='example.com')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(fixtures.response_sparkle_with_dsa,
                                        response.content)
Exemplo n.º 18
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
         is_enabled=False,
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertFalse(version.is_enabled)
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(is_enabled=True))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertTrue(version.is_enabled)
Exemplo n.º 19
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
         is_enabled=False,
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertFalse(version.is_enabled)
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(is_enabled=True))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertTrue(version.is_enabled)
Exemplo n.º 20
0
 def test_factory(self):
     channel = ChannelFactory.create()
     self.assertTrue(Channel.objects.get(id=channel.id))
Exemplo n.º 21
0
 def test_factory(self):
     channel = ChannelFactory.create()
     self.assertTrue(Channel.objects.get(id=channel.id))