Ejemplo n.º 1
0
def make_user_data(user):
    """Make some user data."""
    u = services.get_storage_user(username=user_names[random.randint(0, 4)])
    s = user.root.share(u.id, u"%s to %s" % (user.username, u.username))
    u.get_share(s.id).accept()
    for i in range(10):
        d = user.root.make_subdirectory(u"%s dir%s" % (user.username, i))
        for f in range(10):
            f = d.make_file(u"%s file%s.txt" % (user.username, f))
            uj = f.make_uploadjob(f.content_hash,
                                  get_fake_hash(str(random.random())),
                                  random.randint(1, 100),
                                  random.randint(100, 1000000),
                                  random.randint(100, 1000000))
            uj.commit_content(f.content_hash, uuid.uuid4(), None)
            services.add_music_metadata(uj.file.content_hash, TEST_MUSIC_DATA,
                                        user.shard_id)
    for i in range(10):
        user.make_musicstore_download(random.randint(100, 1000000),
                                      random.randint(1, 100),
                                      u"https://fake.com/%s/%s" % (user.id, i),
                                      u"%s" % user.username,
                                      u"%s Greatest Hits" % user.username,
                                      u"Track %s" % i, "US")
    for i in range(10):
        downloadservices.get_or_make_download(
            user.id, user.root_volume_id,
            u"https://fake.com/%s/%s" % (user.id, i), u"/a/b",
            u"%s%s" % (user.id, i))
Ejemplo n.º 2
0
def make_user_data(user):
    """Make some user data."""
    u = services.get_storage_user(username=user_names[random.randint(0, 4)])
    s = user.root.share(u.id, u"%s to %s" % (user.username, u.username))
    u.get_share(s.id).accept()
    for i in range(10):
        d = user.root.make_subdirectory(u"%s dir%s" % (user.username, i))
        for f in range(10):
            f = d.make_file(u"%s file%s.txt" % (user.username, f))
            uj = f.make_uploadjob(
                f.content_hash, get_fake_hash(str(random.random())),
                random.randint(1, 100), random.randint(100, 1000000),
                random.randint(100, 1000000))
            uj.commit_content(f.content_hash, uuid.uuid4(), None)
            services.add_music_metadata(
                uj.file.content_hash, TEST_MUSIC_DATA, user.shard_id)
    for i in range(10):
        user.make_musicstore_download(
            random.randint(100, 1000000),
            random.randint(1, 100), u"https://fake.com/%s/%s" % (user.id, i),
            u"%s" % user.username, u"%s Greatest Hits" % user.username,
            u"Track %s" % i, "US")
    for i in range(10):
        downloadservices.get_or_make_download(
            user.id, user.root_volume_id,
            u"https://fake.com/%s/%s" % (user.id, i),
            u"/a/b", u"%s%s" % (user.id, i))
Ejemplo n.º 3
0
 def test_get_or_make_download(self):
     """Test get_or_make_download."""
     dl = downloadservices.get_or_make_download(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(dl.owner_id, self.user.id)
     self.assertEquals(dl.volume_id, self.volume_id)
     self.assertEquals(dl.file_path, self.fpath)
     self.assertEquals(dl.download_url, self.dl_url)
     self.assertEquals(dl.download_key, unicode(repr(self.dl_key)))
     # do it again, make sure we get the same one
     dl2 = downloadservices.get_or_make_download(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)
     self.assertEquals(dl.id, dl2.id)
Ejemplo n.º 4
0
 def get_or_make_it(self):
     """Make the download."""
     return downloadservices.get_or_make_download(
         self.user.id, self.volume_id, self.fpath, self.dl_url, self.dl_key)