def handle(self, *args, **options): # Create project project = Project.objects.create(name="Demo", slug="demo", web="https://demo.weblate.org/") # Create main component component = Component.objects.create( name="Gettext", slug="gettext", project=project, vcs="git", repo="https://github.com/WeblateOrg/demo.git", repoweb=("https://github.com/WeblateOrg/weblate/" "blob/{{branch}}/{{filename}}#L{{line}}"), filemask="weblate/langdata/locale/*/LC_MESSAGES/django.po", new_base="weblate/langdata/locale/django.pot", file_format="po", license="GPL-3.0-or-later", ) component.clean() while component.in_progress(): self.stdout.write("Importing base component: {}%".format( component.get_progress()[0])) sleep(1) # Install discovery DiscoveryAddon.create( component, configuration={ "file_format": "po", "match": (r"weblate/locale/(?P<language>[^/]*)/" r"LC_MESSAGES/(?P<component>[^/]*)\.po"), "name_template": "Discovered: {{ component|title }}", "language_regex": "^[^.]+$", "base_file_template": "", "remove": True, }, ) # Manually add Android Component.objects.create( name="Android", slug="android", project=project, vcs="git", repo=component.get_repo_link_url(), filemask="app/src/main/res/values-*/strings.xml", template="app/src/main/res/values/strings.xml", file_format="aresource", license="GPL-3.0-or-later", )
def test_creation(self): addon = DiscoveryAddon.create( self.component, configuration={ 'file_format': 'po', 'match': r'(?P<component>[^/]*)/(?P<language>[^/]*)\.po', 'name_template': '{{ component|title }}', 'language_regex': '^(?!xx).*$', 'base_file_template': '', 'remove': True, }, ) self.assertEqual(self.component.get_linked_childs().count(), 0) addon.perform() self.assertEqual(self.component.get_linked_childs().count(), 3)
def test_creation(self): link = self.component.get_repo_link_url() self.assertEqual(Component.objects.filter(repo=link).count(), 0) addon = DiscoveryAddon.create( self.component, configuration={ "file_format": "po", "match": r"(?P<component>[^/]*)/(?P<language>[^/]*)\.po", "name_template": "{{ component|title }}", "language_regex": "^(?!xx).*$", "base_file_template": "", "remove": True, }, ) self.assertEqual(Component.objects.filter(repo=link).count(), 3) addon.post_update(self.component, "", False) self.assertEqual(Component.objects.filter(repo=link).count(), 3)
def test_creation(self): link = self.component.get_repo_link_url() self.assertEqual(Component.objects.filter(repo=link).count(), 0) addon = DiscoveryAddon.create( self.component, configuration={ 'file_format': 'po', 'match': r'(?P<component>[^/]*)/(?P<language>[^/]*)\.po', 'name_template': '{{ component|title }}', 'language_regex': '^(?!xx).*$', 'base_file_template': '', 'remove': True, }, ) self.assertEqual(Component.objects.filter(repo=link).count(), 3) addon.post_update(self.component, '') self.assertEqual(Component.objects.filter(repo=link).count(), 3)