def test_boot_resource_to_dict_with_sets(self): resource = factory.make_BootResource() resource_set = factory.make_BootResourceSet(resource) dict_representation = boot_resource_to_dict(resource, with_sets=True) self.assertEqual( boot_resource_set_to_dict(resource_set), dict_representation["sets"][resource_set.version], )
def test_boot_resource_set_to_dict(self): resource = factory.make_BootResource() resource_set = factory.make_BootResourceSet(resource) total_size = random.randint(1024, 2048) content = factory.make_bytes(random.randint(512, 1023)) largefile = factory.make_LargeFile(content=content, size=total_size) rfile = factory.make_BootResourceFile(resource_set, largefile) dict_representation = boot_resource_set_to_dict(resource_set) self.assertEqual(resource_set.version, dict_representation['version']) self.assertEqual(resource_set.label, dict_representation['label']) self.assertEqual(resource_set.total_size, dict_representation['size']) self.assertEqual(False, dict_representation['complete']) self.assertEqual(resource_set.progress, dict_representation['progress']) self.assertEqual(boot_resource_file_to_dict(rfile), dict_representation['files'][rfile.filename])