示例#1
0
    def test_TethysAppAdmin_manage_app_storage(self, mock_convert,
                                               mock_get_quota):
        ret = TethysAppAdmin(mock.MagicMock(), mock.MagicMock())
        app = mock.MagicMock()
        app.id = 1
        mock_convert.return_value = '0 bytes'
        mock_get_quota.return_value = {'quota': None}
        url = reverse('admin:clear_workspace', kwargs={'app_id': app.id})

        expected_html = format_html("""
                <span>{} of {}</span>
                <a id="clear-workspace" class="btn btn-danger btn-sm"
                href="{url}">
                Clear Workspace</a>
                """.format('0 bytes', "&#8734;", url=url))
        actual_html = ret.manage_app_storage(app)

        self.assertEquals(expected_html.replace(" ", ""),
                          actual_html.replace(" ", ""))

        mock_convert.return_value = '0 bytes'
        mock_get_quota.return_value = {'quota': 5, 'units': 'gb'}
        url = reverse('admin:clear_workspace', kwargs={'app_id': app.id})

        expected_html = format_html("""
                        <span>{} of {}</span>
                        <a id="clear-workspace" class="btn btn-danger btn-sm"
                        href="{url}">
                        Clear Workspace</a>
                        """.format('0 bytes', "0 bytes", url=url))
        actual_html = ret.manage_app_storage(app)

        self.assertEquals(expected_html.replace(" ", ""),
                          actual_html.replace(" ", ""))
示例#2
0
    def test_TethysAppAdmin(self):
        expected_readonly_fields = (
            'package',
            'manage_app_storage',
        )
        expected_fields = (
            'package',
            'name',
            'description',
            'icon',
            'tags',
            'enabled',
            'show_in_apps_library',
            'enable_feedback',
            'manage_app_storage',
        )
        expected_inlines = [
            CustomSettingInline, PersistentStoreConnectionSettingInline,
            PersistentStoreDatabaseSettingInline, DatasetServiceSettingInline,
            SpatialDatasetServiceSettingInline,
            WebProcessingServiceSettingInline, TethysAppQuotasSettingInline
        ]

        ret = TethysAppAdmin(mock.MagicMock(), mock.MagicMock())

        self.assertEqual(expected_readonly_fields, ret.readonly_fields)
        self.assertEqual(expected_fields, ret.fields)
        self.assertEqual(expected_inlines, ret.inlines)
示例#3
0
 def test_TethysAppAdmin_has_add_permission(self):
     ret = TethysAppAdmin(mock.MagicMock(), mock.MagicMock())
     self.assertFalse(ret.has_add_permission(mock.MagicMock()))