Beispiel #1
0
    def test_generate_hash(self):
        file_ = File()
        file_.version = Version.objects.get(pk=81551)
        filename = self.xpi_path('https-everywhere.xpi')
        assert file_.generate_hash(filename).startswith('sha256:95bd414295acda29c4')

        file_ = File.objects.get(pk=67442)
        with storage.open(file_.file_path, 'wb') as fp:
            fp.write(b'some data\n')
        with storage.open(file_.guarded_file_path, 'wb') as fp:
            fp.write(b'some data guarded\n')
        assert file_.generate_hash().startswith('sha256:5aa03f96c77536579166f')
        file_.status = amo.STATUS_DISABLED
        assert file_.generate_hash().startswith('sha256:6524f7791a35ef4dd4c6f')
        file_.status = amo.STATUS_APPROVED
        assert file_.generate_hash().startswith('sha256:5aa03f96c77536579166f')
Beispiel #2
0
 def get_file(self, platform):
     file = File()  # Real object and not a mock to get the true methods.
     file.version = self.version
     file.pk = 666
     file.platform = platform
     file.status = amo.STATUS_PUBLIC
     file.strict_compatibility = False
     file.binary_components = False
     return file
Beispiel #3
0
 def get_file(self, platform):
     file = File()  # Real object and not a mock to get the true methods.
     file.version = self.version
     file.pk = 666
     file.platform = platform
     file.status = amo.STATUS_PUBLIC
     file.strict_compatibility = False
     file.binary_components = False
     return file