def test_import_basic_bundle_with_appinfo(self): """ Check that a minimal bundle imports without error """ bundle = build_bundle({ 'src/main.c': '', 'appinfo.json': make_appinfo() }) do_import_archive(self.project_id, bundle)
def test_throws_if_sdk2_project_has_array_appkeys(self): """ Throw when trying to import an sdk 2 project with array appkeys """ bundle = build_bundle({ 'src/main.c': '', 'appinfo.json': make_appinfo(options={'appKeys': [], 'sdkVersion': '2'}) }) with self.assertRaises(ValidationError): do_import_archive(self.project_id, bundle)
def check_appinfo_manifest(self, manifest, package_options=None): """ Check that a generated manifest file looks like a manually assembled manifest file :param manifest: Manifest to check :param package_options: root-level options to set in the 'correct' manifest file """ package_options = {} if package_options is None else package_options package_options['uuid'] = str(self.project.app_uuid) compare_to = make_appinfo(package_options) self.assertDictEqual(json.loads(manifest), json.loads(compare_to))
def check_appinfo_manifest(self, manifest, package_options=None): """ Check that a generated manifest file looks like a manually assembled manifest file :param manifest: Manifest to check :param package_options: root-level options to set in the 'correct' manifest file """ package_options = {} if package_options is None else package_options package_options["uuid"] = str(self.project.app_uuid) compare_to = make_appinfo(package_options) self.assertDictEqual(json.loads(manifest), json.loads(compare_to))
def test_import_appinfo_with_resources(self): """ Check that a resource can be imported in an appinfo.json project """ bundle = build_bundle({ 'src/main.c': '', 'resources/images/blah.png': 'contents!', 'appinfo.json': make_appinfo(options=self.make_resource_spec()) }) do_import_archive(self.project_id, bundle) project = Project.objects.get(pk=self.project_id) self.assertEqual(project.resources.get().variants.get().get_contents(), 'contents!')
def test_import_appinfo_with_resources(self): """ Check that a resource can be imported in an appinfo.json project """ bundle = build_bundle({ 'src/main.c': '', 'resources/images/blah.png': 'contents!', 'appinfo.json': make_appinfo(options=RESOURCE_SPEC) }) do_import_archive(self.project_id, bundle) project = Project.objects.get(pk=self.project_id) self.assertEqual(project.resources.get().variants.get().get_contents(), 'contents!')
def test_throws_with_invalid_appinfo(self): """ Check that appinfo validation is performed with a few invalid values """ invalid_things = [ ('projectType', 'invalid'), ('sdkVersion', '1'), ('versionLabel', '01.0'), ] for k, v in invalid_things: bundle = build_bundle({ 'src/main.c': '', 'appinfo.json': make_appinfo({k: v}) }) with self.assertRaises(ValidationError): do_import_archive(self.project_id, bundle)
def make_custom_manifests(messageKeys): # We want to specify as many optional options as possible, in the hope that they all get exported # identically after being imported. npm_options = { 'package_options': { 'dependencies': { 'some_package': '11.11.0' }, 'keywords': ['earth', 'wind', 'fire', 'water'], }, 'pebble_options': { 'messageKeys': messageKeys } } appinfo_options = {'appKeys': messageKeys} return make_package(**npm_options), make_appinfo(appinfo_options)
def make_custom_manifests(messageKeys): # We want to specify as many optional options as possible, in the hope that they all get exported # identically after being imported. npm_options = { 'package_options': { 'dependencies': {'some_package': '11.11.0'}, 'keywords': ['earth', 'wind', 'fire', 'water'], }, 'pebble_options': { 'messageKeys': messageKeys } } appinfo_options = { 'appKeys': messageKeys } return make_package(**npm_options), make_appinfo(appinfo_options)