File: test_s3_url_resource.py

package info (click to toggle)
python-maggma 0.70.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,416 kB
  • sloc: python: 10,150; makefile: 12
file content (27 lines) | stat: -rw-r--r-- 717 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest

from maggma.api.resource import S3URLResource
from maggma.stores import MemoryStore


@pytest.fixture()
def entries_store():
    store = MemoryStore("entries", key="url")
    store.connect()
    return store


def test_init(entries_store):
    resource = S3URLResource(store=entries_store, url_lifetime=500)
    assert len(resource.router.routes) == 2


def test_msonable(entries_store):
    resource = S3URLResource(store=entries_store, url_lifetime=500)
    endpoint_dict = resource.as_dict()

    for k in ["@class", "@module", "store", "model"]:
        assert k in endpoint_dict

    assert isinstance(endpoint_dict["model"], str)
    assert endpoint_dict["model"] == "maggma.api.models.S3URLDoc"