本文整理汇总了Python中corehq.apps.builds.models.BuildSpec类的典型用法代码示例。如果您正苦于以下问题:Python BuildSpec类的具体用法?Python BuildSpec怎么用?Python BuildSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuildSpec类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_apk_version
def clean_apk_version(self):
# make sure it points to a valid BuildSpec
apk_version = self.cleaned_data['apk_version']
if apk_version == LATEST_APK_VALUE:
return apk_version
try:
BuildSpec.from_string(apk_version)
return apk_version
except ValueError:
raise forms.ValidationError(
_('Invalid APK version %(version)s'), params={'version': apk_version})
示例2: commcare_version_report
def commcare_version_report(request, template="hqadmin/commcare_version.html"):
apps = get_db().view("app_manager/applications_brief").all()
menu = CommCareBuildConfig.fetch().menu
builds = [item.build.to_string() for item in menu]
by_build = dict([(item.build.to_string(), {"label": item.label, "apps": []}) for item in menu])
for app in apps:
app = app["value"]
app["id"] = app["_id"]
if app.get("build_spec"):
build_spec = BuildSpec.wrap(app["build_spec"])
build = build_spec.to_string()
if by_build.has_key(build):
by_build[build]["apps"].append(app)
else:
by_build[build] = {"label": build_spec.get_label(), "apps": [app]}
builds.append(build)
tables = []
for build in builds:
by_build[build]["build"] = build
tables.append(by_build[build])
context = get_hqadmin_base_context(request)
context.update({"tables": tables})
context["hide_filters"] = True
return render(request, template, context)
示例3: make_app
def make_app(self, spec):
app = Application.new_app('domain', "Untitled Application", application_version=APP_V2)
app.build_spec = BuildSpec.from_string('2.9.0/latest')
case_type = "frog"
for m_spec in spec["m"]:
m_type = m_spec['type']
m_class = Module if m_type == 'basic' else AdvancedModule
module = app.add_module(m_class.new_module(m_spec['name'], None))
module.unique_id = m_spec['name']
module.case_type = m_spec.get("case_type", "frog")
module.root_module_id = m_spec.get("parent", None)
for f_spec in m_spec['f']:
form_name = f_spec["name"]
form = app.new_form(module.id, form_name, None)
form.unique_id = form_name
for a_spec in f_spec.get('actions', []):
if isinstance(a_spec, dict):
action = a_spec['action']
case_type = a_spec.get("case_type", case_type)
parent = a_spec.get("parent", None)
else:
action = a_spec
if 'open' == action:
if m_type == "basic":
form.actions.open_case = OpenCaseAction(name_path="/data/question1")
form.actions.open_case.condition.type = 'always'
else:
form.actions.open_cases.append(AdvancedOpenCaseAction(
case_type=case_type,
case_tag='open_{}'.format(case_type),
name_path='/data/name'
))
elif 'update' == action:
if m_type == "basic":
form.requires = 'case'
form.actions.update_case = UpdateCaseAction(update={'question1': '/data/question1'})
form.actions.update_case.condition.type = 'always'
else:
form.actions.load_update_cases.append(LoadUpdateAction(
case_type=case_type,
case_tag='update_{}'.format(case_type),
parent_tag=parent,
))
elif 'open_subacse':
if m_type == "basic":
form.actions.subcases.append(OpenSubCaseAction(
case_type=case_type,
case_name="/data/question1",
condition=FormActionCondition(type='always')
))
else:
form.actions.open_cases.append(AdvancedOpenCaseAction(
case_type=case_type,
case_tag='subcase_{}'.format(case_type),
name_path='/data/name',
parent_tag=parent
))
return app
示例4: setUpClass
def setUpClass(cls):
cls.domain = Domain(name='app-manager-testviews-domain', is_active=True)
cls.domain.save()
cls.username = 'cornelius'
cls.password = 'fudge'
cls.user = WebUser.create(cls.domain.name, cls.username, cls.password, is_active=True)
cls.user.is_superuser = True
cls.user.save()
cls.build = add_build(version='2.7.0', build_number=20655)
cls.app = Application.new_app(cls.domain.name, "TestApp", application_version=APP_V1)
cls.app.build_spec = BuildSpec.from_string('2.7.0/latest')
toggles.CUSTOM_PROPERTIES.set("domain:{domain}".format(domain=cls.domain.name), True)
示例5: get_latest_apk_version
def get_latest_apk_version(self):
from corehq.apps.app_manager.models import LATEST_APK_VALUE
from corehq.apps.builds.models import BuildSpec
from corehq.apps.builds.utils import get_default_build_spec
if self.app.global_app_config.apk_prompt == "off":
return {}
else:
configured_version = self.app.global_app_config.apk_version
if configured_version == LATEST_APK_VALUE:
value = get_default_build_spec().version
else:
value = BuildSpec.from_string(configured_version).version
force = self.app.global_app_config.apk_prompt == "forced"
return {"value": value, "force": force}
示例6: test_suite_media_with_app_profile
def test_suite_media_with_app_profile(self, *args):
# Test that suite includes only media relevant to the profile
app = Application.new_app('domain', "my app")
app.add_module(Module.new_module("Module 1", None))
app.new_form(0, "Form 1", None)
app.build_spec = BuildSpec.from_string('2.21.0/latest')
app.build_profiles = OrderedDict({
'en': BuildProfile(langs=['en'], name='en-profile'),
'hin': BuildProfile(langs=['hin'], name='hin-profile'),
'all': BuildProfile(langs=['en', 'hin'], name='all-profile'),
})
app.langs = ['en', 'hin']
image_path = 'jr://file/commcare/module0_en.png'
audio_path = 'jr://file/commcare/module0_en.mp3'
app.get_module(0).set_icon('en', image_path)
app.get_module(0).set_audio('en', audio_path)
# Generate suites and default app strings for each profile
suites = {}
locale_ids = {}
for build_profile_id in app.build_profiles.keys():
suites[build_profile_id] = app.create_suite(build_profile_id=build_profile_id)
default_app_strings = app.create_app_strings('default', build_profile_id)
locale_ids[build_profile_id] = {line.split('=')[0] for line in default_app_strings.splitlines()}
# Suite should have only the relevant images
media_xml = self.makeXML("modules.m0", "modules.m0.icon", "modules.m0.audio")
self.assertXmlPartialEqual(media_xml, suites['all'], "././menu[@id='m0']/display")
no_media_xml = self.XML_without_media("modules.m0")
self.assertXmlPartialEqual(media_xml, suites['en'], "././menu[@id='m0']/display")
no_media_xml = self.XML_without_media("modules.m0")
self.assertXmlPartialEqual(no_media_xml, suites['hin'], "././menu[@id='m0']/text")
# Default app strings should have only the relevant locales
self.assertIn('modules.m0', locale_ids['all'])
self.assertIn('modules.m0.icon', locale_ids['all'])
self.assertIn('modules.m0.audio', locale_ids['all'])
self.assertIn('modules.m0', locale_ids['en'])
self.assertIn('modules.m0.icon', locale_ids['en'])
self.assertIn('modules.m0.audio', locale_ids['en'])
self.assertIn('modules.m0', locale_ids['hin'])
self.assertNotIn('modules.m0.icon', locale_ids['hin'])
self.assertNotIn('modules.m0.audio', locale_ids['hin'])
示例7: test_update_form_references_case_list_form
def test_update_form_references_case_list_form(self):
app = Application.new_app('domain', 'Foo')
app.modules.append(Module(forms=[Form()]))
app.modules.append(Module(forms=[Form()]))
app.build_spec = BuildSpec.from_string('2.7.0/latest')
app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.0')
app.get_module(1).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-1')
original_form_id = app.get_module(1).get_form(0).unique_id
app.get_module(0).case_list_form.form_id = original_form_id
copy = Application.from_source(app.export_json(dump_json=False), 'domain')
new_form_id = copy.get_module(1).get_form(0).unique_id
self.assertNotEqual(original_form_id, new_form_id)
self.assertEqual(new_form_id, copy.get_module(0).case_list_form.form_id)
示例8: test_update_form_references_form_link
def test_update_form_references_form_link(self):
app = Application.new_app('domain', 'Foo')
app.modules.append(Module(forms=[Form()]))
app.modules.append(Module(forms=[Form(), Form()]))
app.build_spec = BuildSpec.from_string('2.7.0/latest')
app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.0')
app.get_module(1).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-1')
original_form_id1 = app.get_module(1).get_form(0).unique_id
original_form_id2 = app.get_module(1).get_form(1).unique_id
app.get_module(0).get_form(0).form_links = [
FormLink(xpath="", form_id=original_form_id1),
FormLink(xpath="", form_id=original_form_id2),
]
copy = Application.from_source(app.export_json(dump_json=False), 'domain')
new_form_id1 = copy.get_module(1).get_form(0).unique_id
new_form_id2 = copy.get_module(1).get_form(1).unique_id
self.assertNotEqual(original_form_id1, new_form_id1)
self.assertNotEqual(original_form_id2, new_form_id2)
self.assertEqual(new_form_id1, copy.get_module(0).get_form(0).form_links[0].form_id)
self.assertEqual(new_form_id2, copy.get_module(0).get_form(0).form_links[1].form_id)
示例9: test
def test(self, mock):
add_build(version='2.7.0', build_number=20655)
domain = 'form-versioning-test'
# set up inital app
app = Application.new_app(domain, 'Foo')
app.modules.append(Module(forms=[Form(), Form()]))
app.build_spec = BuildSpec.from_string('2.7.0/latest')
app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.0')
app.get_module(0).get_form(1).source = BLANK_TEMPLATE.format(xmlns='xmlns-1')
app.save()
# make a build
build1 = app.make_build()
build1.save()
# modify first form
app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.1')
app.save()
# make second build
build2 = app.make_build()
build2.save()
# modify first form
app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.2')
app.save()
app.save()
app.save()
# make third build
build3 = app.make_build()
build3.save()
self.assertEqual(self.get_form_versions(build1), [1, 1])
self.assertEqual(self.get_form_versions(build2), [2, 1])
self.assertEqual(self.get_form_versions(build3), [5, 1])
# revert to build2
app = app.make_reversion_to_copy(build2)
app.save()
# make reverted build
build4 = app.make_build()
build4.save()
self.assertEqual(self.get_form_versions(build4), [6, 1])
# copy app
xxx_app = import_app(app.export_json(dump_json=False), domain)
# make build of copy
xxx_build1 = xxx_app.make_build()
xxx_build1.save()
# modify first form of copy app
xxx_app.get_module(0).get_form(0).source = BLANK_TEMPLATE.format(xmlns='xmlns-0.xxx.0')
xxx_app.save()
# make second build of copy
xxx_build2 = xxx_app.make_build()
xxx_build2.save()
self.assertEqual(self.get_form_versions(xxx_build1), [1, 1])
self.assertEqual(self.get_form_versions(xxx_build2), [2, 1])
示例10: setUp
def setUp(self):
self.app = Application.new_app(self.project.name, "TestApp")
self.app.build_spec = BuildSpec.from_string('2.7.0/latest')
self.client.login(username=self.username, password=self.password)
示例11: setUp
def setUp(self):
self.app = Application.new_app("domain", "my app", application_version=APP_V2)
self.module = self.app.add_module(Module.new_module("Module 1", None))
self.form = self.app.new_form(0, "Form 1", None)
self.min_spec = BuildSpec.from_string("2.21/latest")
self.app.build_spec = self.min_spec