Skip to content

Commit

Permalink
updates for tethys 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeymac committed Aug 17, 2024
1 parent c196acd commit 9909b9b
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 70 deletions.
16 changes: 10 additions & 6 deletions install.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file should be committed to your app code.
version: 1.0
version: 1.1
# This should be greater or equal to your tethys-platform in your environment
tethys_version: ">=4.0.0"
# This should match the app - package name in your setup.py
name: thredds_tutorial

Expand All @@ -8,11 +10,13 @@ requirements:
skip: false
conda:
channels:
- conda-forge
- conda-forge
packages:
- netcdf4
- siphon
- owslib
- netcdf4
- siphon
- owslib
pip:

post:
npm:

post:
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
dependencies = []

# -- Get Resource File -- #
resource_files = find_all_resource_files(app_package, TethysAppBase.package_namespace)

resource_files = find_all_resource_files(
app_package, TethysAppBase.package_namespace
)

setup(
name=release_package,
Expand All @@ -28,4 +29,4 @@
include_package_data=True,
zip_safe=False,
install_requires=dependencies,
)
)
2 changes: 1 addition & 1 deletion tethysapp/thredds_tutorial/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Included for native namespace package support
# Included for native namespace package support
6 changes: 2 additions & 4 deletions tethysapp/thredds_tutorial/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from tethys_sdk.base import TethysAppBase
from tethys_sdk.app_settings import SpatialDatasetServiceSetting


class ThreddsTutorial(TethysAppBase):
class App(TethysAppBase):
"""
Tethys app class for Thredds Tutorial.
"""

name = 'THREDDS Tutorial'
name = 'Thredds Tutorial'
description = ''
package = 'thredds_tutorial' # WARNING: Do not change this value
index = 'home'
Expand Down
35 changes: 18 additions & 17 deletions tethysapp/thredds_tutorial/controllers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.shortcuts import render
from tethys_sdk.routing import controller
from tethys_sdk.gizmos import Button
from .app import App


@controller
def home(request):
Expand All @@ -13,9 +14,9 @@ def home(request):
icon='save',
style='success',
attributes={
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Save'
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'top',
'title': 'Save'
}
)

Expand All @@ -25,9 +26,9 @@ def home(request):
icon='pen',
style='warning',
attributes={
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Edit'
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'top',
'title': 'Edit'
}
)

Expand All @@ -37,29 +38,29 @@ def home(request):
icon='trash',
style='danger',
attributes={
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Remove'
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'top',
'title': 'Remove'
}
)

previous_button = Button(
display_text='Previous',
name='previous-button',
attributes={
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Previous'
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'top',
'title': 'Previous'
}
)

next_button = Button(
display_text='Next',
name='next-button',
attributes={
'data-bs-toggle':'tooltip',
'data-bs-placement':'top',
'title':'Next'
'data-bs-toggle': 'tooltip',
'data-bs-placement': 'top',
'title': 'Next'
}
)

Expand All @@ -71,4 +72,4 @@ def home(request):
'next_button': next_button
}

return render(request, 'thredds_tutorial/home.html', context)
return App.render(request, 'home.html', context)
3 changes: 0 additions & 3 deletions tethysapp/thredds_tutorial/handoff.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "tethys_apps/app_base.html" %}

{% load static %}
{% load static tethys %}

{% block title %}{{ tethys_app.name }}{% endblock %}

Expand Down Expand Up @@ -33,10 +33,10 @@

{% block content_dependent_styles %}
{{ block.super }}
<link href="{% static 'thredds_tutorial/css/main.css' %}" rel="stylesheet"/>
<link href="{% static tethys_app|public:'css/main.css' %}" rel="stylesheet"/>
{% endblock %}

{% block scripts %}
{{ block.super }}
<script src="{% static 'thredds_tutorial/js/main.js' %}" type="text/javascript"></script>
<script src="{% static tethys_app|public:'js/main.js' %}" type="text/javascript"></script>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "thredds_tutorial/base.html" %}
{% load tethys_gizmos %}
{% extends tethys_app.package|add:"/base.html" %}
{% load tethys %}

{% block header_buttons %}
<div class="header-button glyphicon-button" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Help">
Expand Down
44 changes: 13 additions & 31 deletions tethysapp/thredds_tutorial/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# Most of your test classes should inherit from TethysTestCase
from tethys_sdk.testing import TethysTestCase

# Use if your app has persistent stores that will be tested against.
# Your app class from app.py must be passed as an argument to the TethysTestCase functions to both
# create and destroy the temporary persistent stores for your app used during testing
# from ..app import ThreddsTutorial

# Use if you'd like a simplified way to test rendered HTML templates.
# You likely need to install BeautifulSoup, as it is not included by default in Tethys Platform
# 1. Open a terminal
# 2. Enter command ". /usr/lib/tethys/bin/activate" to activate the Tethys python environment
# 3. Enter command "pip install beautifulsoup4"
# For help, see https://www.crummy.com/software/BeautifulSoup/bs4/doc/
# For testing rendered HTML templates it may be helpful to use BeautifulSoup.
# from bs4 import BeautifulSoup
# For help, see https://www.crummy.com/software/BeautifulSoup/bs4/doc/


"""
To run any tests:
1. Open a terminal
2. Enter command ". /usr/lib/tethys/bin/activate" to activate the Tethys python environment
3. In portal_config.yml make sure that the default database user is set to tethys_super or is a super user of the database
To run tests for an app:
1. Open a terminal and activate the Tethys environment::
conda activate tethys
2. In portal_config.yml make sure that the default database user is set to tethys_super or is a super user of the database
DATABASES:
default:
ENGINE: django.db.backends.postgresql_psycopg2
Expand All @@ -28,28 +23,15 @@
HOST: 127.0.0.1
PORT: 5435
4. Enter tethys test command.
The general form is: "tethys test -f tethys_apps.tethysapp.<app_name>.<folder_name>.<file_name>.<class_name>.<function_name>"
See below for specific examples
To run all tests across this app:
Test command: "tethys test -f tethys_apps.tethysapp.thredds_tutorial"
3. From the root directory of your app, run the ``tethys manage test`` command::
To run all tests in this file:
Test command: "tethys test -f tethys_apps.tethysapp.thredds_tutorial.tests.tests"
tethys manage test tethysapp/<app_name>/tests
To run tests in the ThreddsTutorialTestCase class:
Test command: "tethys test -f tethys_apps.tethysapp.thredds_tutorial.tests.tests.ThreddsTutorialTestCase"
To run only the test_if_tethys_platform_is_great function in the ThreddsTutorialTestCase class:
Test command: "tethys test -f tethys_apps.tethysapp.thredds_tutorial.tests.tests.ThreddsTutorialTestCase.test_if_tethys_platform_is_great"
To learn more about writing tests, see:
https://docs.djangoproject.com/en/1.9/topics/testing/overview/#writing-tests
https://docs.python.org/2.7/library/unittest.html#module-unittest
https://docs.tethysplatform.org/en/stable/tethys_sdk/testing.html
"""


class ThreddsTutorialTestCase(TethysTestCase):
"""
In this class you may define as many functions as you'd like to test different aspects of your app.
Expand Down
Empty file.

0 comments on commit 9909b9b

Please sign in to comment.