Skip to content

Commit

Permalink
Add custom table header test
Browse files Browse the repository at this point in the history
  • Loading branch information
duytnguyendtn committed Jul 23, 2024
1 parent 1ae3eb8 commit ea36f51
Showing 1 changed file with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
from jdaviz.configs.default.plugins.virtual_observatory.vo_plugin import vo_plugin_label


class fake_siaresult:
def __init__(self, attrs):
for attr, value in attrs.items():
self.__setattr__(attr, value)

def getdataurl(self):
return "Fake URL"


# TODO: Update all _obj calls to formal API calls once Plugin API is available
class TestVOImvizLocal(BaseImviz_WCS_WCS):
def test_autocenter_coords(self):
Expand All @@ -25,17 +34,14 @@ def test_autocenter_coords(self):
assert vo_plugin.source == "337.51924057481 -20.83208305686149"

def test_populate_table_default_headers(self):
class fake_siaresult:
def __init__(self):
self.title = "Fake Title"
self.instr = "Fake Instrument"
self.dateobs = "Fake Dateobs"

def getdataurl(self):
return "Fake URL"

vo_plugin = self.imviz.plugins[vo_plugin_label]._obj
fake_result = fake_siaresult()
fake_result = fake_siaresult(
{
"title": "Fake Title",
"instr": "Fake Instrument",
"dateobs": "Fake Dateobs",
}
)
vo_plugin._populate_table([fake_result])

assert vo_plugin.table.items == [
Expand All @@ -47,6 +53,28 @@ def getdataurl(self):
}
]

def test_populate_table_customm_headers(self):
vo_plugin = self.imviz.plugins[vo_plugin_label]._obj
fake_result = fake_siaresult(
{
"attrA": "Field A",
"attrB": "Field B",
"attrC": "Field C",
}
)
vo_plugin._populate_table(
[fake_result], {"Title A": "attrA", "Title B": "attrB", "Title C": "attrC"}
)

assert vo_plugin.table.items == [
{
"URL": fake_result.getdataurl(),
"Title A": fake_result.attrA,
"Title B": fake_result.attrB,
"Title C": fake_result.attrC,
}
]


@pytest.mark.remote_data
class TestVOImvizRemote:
Expand Down

0 comments on commit ea36f51

Please sign in to comment.