Add basic tests framework

This commit is contained in:
2024-07-08 20:05:45 +01:00
parent 7bd1cec4bb
commit 421843757f
7 changed files with 162 additions and 1 deletions

0
tests/__init__.py Normal file
View File

View File

@@ -0,0 +1 @@
{"api":"0.13","space":"Leigh Hackspace","logo":"https://raw.githubusercontent.com/leigh-hackspace/logos-graphics-assets/master/logo/rose_logo.svg","url":"https://leighhack.org/","location":{"address":"Leigh Hackspace, Unit 3.14, 3rd Floor, Leigh Spinners Mill, Park Lane, Leigh, WN7 2LB, United Kingdom","lat":53.493497,"lon":-2.493479,"timezone":"Europe/London","ext_osm_node":4300807520},"state":{"open":true,"lastchange":1720439671},"contact":{"twitter":"@leigh_hackspace","email":"info@leighhack.org","mastodon":"@leigh_hackspace@mastodon.social","ext_slack":"leighhack.slack.com","ext_instagram":"leighhackspace"},"issue_report_channels":["email"],"sensors":{"temperature":[{"value":22.91,"location":"Pi Room","unit":"°C"},{"value":23.6,"location":"Fabrication","unit":"°C"},{"value":24.0,"location":"Workshop","unit":"°C"},{"value":22.8,"location":"Main Space","unit":"°C"},{"value":22.8,"location":"Dark Room","unit":"°C"},{"value":23.7,"location":"Craft Space","unit":"°C"},{"value":22.4,"location":"Social Space","unit":"°C"},{"value":19.8,"location":"Outside","unit":"°C"}],"humidity":[{"value":54.92,"location":"Pi Room","unit":"%"},{"value":49.0,"location":"Fabrication","unit":"%"},{"value":51.0,"location":"Workshop","unit":"%"},{"value":50.0,"location":"Main Space","unit":"%"},{"value":50.0,"location":"Dark Room","unit":"%"},{"value":46.0,"location":"Craft Space","unit":"%"},{"value":61.0,"location":"Social Space","unit":"%"},{"value":60.0,"location":"Outside","unit":"%"}],"network_connections":[{"value":23.0,"location":"WiFi Clients","type":"wifi"}],"total_member_count":[{"value":24.0,"name":"Active Members"}],"ext_3d_printers":[{"name":"3D-1","state":"offline","lastchange":1720454454},{"name":"3D-2","state":"offline","lastchange":1719845534},{"name":"3D-3","state":"offline","lastchange":1720454466}]},"feeds":{"blog":{"type":"rss","url":"https://leighhack.org/blog/index.xml"},"calendar":{"type":"ical","url":"http://api.leighhack.org/events.ics"}},"api_compatibility":["13","14"],"links":[{"name":"Github","url":"https://github.com/leigh-hackspace"},{"name":"Slack","url":"https://join.slack.com/t/leighhack/shared_invite/enQtNDYzMjEyMDMxNDExLTE1MWY5N2IwMzdhMzQ0ZWFiNDkyNzJmMGM1ZmFkODcwMGM5ODFmYmI4MjhmM2JiMWEyY2E3NTRjMTQzMzljZWU"},{"name":"Discourse","url":"https://discourse.leighhack.org/"},{"name":"Join Leigh Hackspace","url":"https://leighhack.org/membership/"}],"membership_plans":[{"name":"Member","value":24,"currency":"GBP","billing_interval":"monthly","description":"Our standard membership that allows usage of the hackspace facilities.","ext_link":"https://pay.gocardless.com/AL00024VQTCKBK"},{"name":"Member+","value":30,"currency":"GBP","billing_interval":"monthly","description":"Standard membership with an additional donation.","ext_link":"https://pay.gocardless.com/AL00024VQW2FWQ"},{"name":"Concession","value":18,"currency":"GBP","billing_interval":"monthly","description":"A subsidised membership for pensioners, students, and low income earners.","ext_link":"https://pay.gocardless.com/AL0002BMN4S3AX"},{"name":"Family","value":40,"currency":"GBP","billing_interval":"monthly","description":"A discounted family membership for two adults and two children.","ext_link":"https://pay.gocardless.com/AL000637J3VZP7"},{"name":"Day Pass","value":5,"currency":"GBP","billing_interval":"daily","description":"Access to the hackspace's facilities for a day.","ext_link":"mailto:info@leighhack.org?subject=Day%20Pass"},{"name":"Patron","value":5,"currency":"GBP","billing_interval":"monthly","description":"Support the hackspace without being a member.","ext_link":"https://pay.gocardless.com/AL000FDGN4Q6AC"}],"ext_dabo":"Dabo!"}

17
tests/test_v13.py Normal file
View File

@@ -0,0 +1,17 @@
import pytest
import json
import pathlib
from pydantic_spaceapi.v13 import SpaceAPIv13Model
@pytest.fixture
def valid_v13():
file = pathlib.Path("tests/examples/valid_v13.json")
with open(file) as f:
return json.loads(f.read())
def test_working(valid_v13):
"""
Check that we can parse a valid v13 definition
"""
obj = SpaceAPIv13Model(**valid_v13)
assert isinstance(obj, SpaceAPIv13Model)