def set_browser_versions(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', { 'version_lower_bound': AsType('any', 'CHAR'), 'version_upper_bound': AsType('any', 'CHAR') }))
def set_default_bounds_for_bookmarks_count(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'bookmarks_count_lower_bound': AsType(-1, 'INTEGER')})) Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'bookmarks_count_upper_bound': AsType(-1, 'INTEGER')}))
def migrate_aboutaccounts_snippets(apps, schema_editor): """Migrate existing snippets that used about:accounts link filtering.""" Snippet = apps.get_model('base', 'Snippet') Snippet.objects.filter(data__icontains='href=\\"about:accounts').update( client_options=ColumnAdd('client_options', {'has_fxaccount': AsType('yes', 'CHAR')})) Snippet.objects.exclude(data__icontains='href=\\"about:accounts').update( client_options=ColumnAdd('client_options', {'has_fxaccount': AsType('any', 'CHAR')}))
def test_add_update_typed(self): DynamicModel.objects.update( attrs=ColumnAdd('attrs', {'over': AsType(9000, 'DOUBLE')}), ) m = DynamicModel.objects.get() assert isinstance(m.attrs['over'], float) assert m.attrs['over'] == 9000.0
def test_add_update_typed(self): DynamicModel.objects.update( attrs=ColumnAdd("attrs", {"over": AsType(9000, "DOUBLE")}) ) m = DynamicModel.objects.get() assert isinstance(m.attrs["over"], float) assert m.attrs["over"] == 9000.0
def set_is_developer(apps, schema_editor): """Migrate existing snippets that used about:accounts link filtering.""" Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update( client_options=ColumnAdd('client_options', { 'is_developer': AsType('any', 'CHAR'), }))
def migrate_has_testpilot(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.filter(client_options__has_testpilot_CHAR='yes').update( client_options=ColumnAdd( 'client_options', { 'addon_check_type': AsType('installed', 'CHAR'), 'addon_name': AsType('@testpilot-addon', 'CHAR'), })) Snippet.objects.filter(client_options__has_testpilot_CHAR='no').update( client_options=ColumnAdd( 'client_options', { 'addon_check_type': AsType('not_installed', 'CHAR'), 'addon_name': AsType('@testpilot-addon', 'CHAR'), })) Snippet.objects.filter(client_options__has_testpilot_CHAR='any').update( client_options=ColumnAdd( 'client_options', { 'addon_check_type': AsType('any', 'CHAR'), 'addon_name': AsType('', 'CHAR'), }))
def set_isdefaultbrowser_clientoption(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'is_default_browser': AsType('any', 'CHAR')}))
def test_as_type_instantiation(self): with pytest.raises(ValueError) as excinfo: AsType(1, 'PANTS') assert "Invalid data_type 'PANTS'" in str(excinfo.value)
def set_default_resolutions(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') resolutions = '0-1024;1024-1920;1920-50000' Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'screen_resolutions': AsType(resolutions, 'CHAR')}))
def set_has_testpilot(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'has_testpilot': AsType('any', 'CHAR')}))
def migrate_aboutaccounts_snippets(apps, schema_editor): """Migrate existing snippets that used about:accounts link filtering.""" Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'has_testpilot': AsType('any', 'CHAR')}))
def test_add_update_typed_expressions(self): DynamicModel.objects.update(attrs=ColumnAdd( "attrs", {Value("over"): AsType(Value(9000), "DOUBLE")})) m = DynamicModel.objects.get() assert isinstance(m.attrs["over"], float) assert m.attrs["over"] == 9000.0