Repository: NSLS-II/sirepo-bluesky (language: python)

Issue:
Use sirepo via docker for tests
Here is an example of a successful test: https://travis-ci.com/mrakitin/sirepo-bluesky/jobs/293281770.

attn @AbbyGi 


Discussion / hints:
# [Codecov](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=h1) Report
> Merging [#3](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=desc) into [master](https://codecov.io/gh/NSLS-II/sirepo-bluesky/commit/83a14cffe9709df8b1958cc360e9ead9ff68bdeb?src=pr&el=desc) will **increase** coverage by `0.45%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3/graphs/tree.svg?width=650&token=KmHf39eODY&height=150&src=pr)](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master       #3      +/-   ##
==========================================
+ Coverage   87.45%   87.91%   +0.45%     
==========================================
  Files           7        7              
  Lines         558      579      +21     
==========================================
+ Hits          488      509      +21     
  Misses         70       70
```


| [Impacted Files](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [sirepo\_bluesky/tests/test\_sirepo\_det.py](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3/diff?src=pr&el=tree#diff-c2lyZXBvX2JsdWVza3kvdGVzdHMvdGVzdF9zaXJlcG9fZGV0LnB5) | `100% <100%> (ø)` | :arrow_up: |
| [sirepo\_bluesky/tests/test\_sirepo\_flyer.py](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3/diff?src=pr&el=tree#diff-c2lyZXBvX2JsdWVza3kvdGVzdHMvdGVzdF9zaXJlcG9fZmx5ZXIucHk=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=footer). Last update [83a14cf...e017862](https://codecov.io/gh/NSLS-II/sirepo-bluesky/pull/3?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

This is ready to go. @AbbyGi, feel free to merge.
Thanks @AbbyGi.

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index 940a196d..6600ef47 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,16 +18,12 @@ cache:
 jobs:
   fast_finish: true
   include:
-    - os: linux
-      python: 3.6
     - os: linux
       python: 3.7
     - os: linux
       python: 3.8
-    - os: linux
-      python: 3.6
-      env:
-        - USE_DOCKER: true
+    # - os: linux
+    #   python: 3.9
     - os: linux
       python: 3.7
       env:
@@ -36,6 +32,10 @@ jobs:
       python: 3.8
       env:
         - USE_DOCKER: true
+    #  - os: linux
+    #    python: 3.9
+    #    env:
+    #      - USE_DOCKER: true
 
 install:
   - env | sort -u
@@ -45,7 +45,8 @@ install:
   - pip install -r requirements-dev.txt
   - pip install --upgrade numpy pip
   - pip list
-  - mkdir -p $HOME/.config/databroker/ && cp -v examples/local.yml $HOME/.config/databroker/local.yml
+  # Removed for testing entry point feature.
+  #- mkdir -p $HOME/.config/databroker/ && cp -v examples/local.yml $HOME/.config/databroker/local.yml
   - |
     if [ ! -z "$USE_DOCKER" ]; then
         docker pull radiasoft/sirepo:beta
@@ -55,12 +56,14 @@ script:
   - flake8  # Enforce code style ('relaxed' line length limit is set in .flake8 config file).
   - |
     if [ ! -z "$USE_DOCKER" ]; then
-        container_id=$(docker run -d -t --init --rm --name sirepo -e SIREPO_AUTH_METHODS=bluesky:guest -e SIREPO_AUTH_BLUESKY_SECRET=bluesky -e SIREPO_SRDB_ROOT=/sirepo -e SIREPO_COOKIE_IS_SECURE=false -p 8000:8000 -v $PWD/sirepo_bluesky/tests/SIREPO_SRDB_ROOT:/SIREPO_SRDB_ROOT:ro,z radiasoft/sirepo:beta bash -l -c "mkdir -v -p /sirepo/user/ && cp -Rv /SIREPO_SRDB_ROOT/* /sirepo/user/ && sirepo service http")
-        coverage run -m pytest -vvvv -m "docker"  # Run the tests and check for test coverage.
+        container_id=$(docker run -d -t --init --rm --name sirepo -e SIREPO_AUTH_METHODS=bluesky:guest -e SIREPO_AUTH_BLUESKY_SECRET=bluesky -e SIREPO_SRDB_ROOT=/sirepo -e SIREPO_COOKIE_IS_SECURE=false -p 8000:8000 -v $PWD/sirepo_bluesky/tests/SIREPO_SRDB_ROOT:/SIREPO_SRDB_ROOT:ro,z radiasoft/sirepo:beta bash -l -c "mkdir -v -p /sirepo/ && cp -Rv /SIREPO_SRDB_ROOT/* /sirepo/ && sirepo service http")
+        pytest -vvvv -m "docker"  # Run the tests and check for test coverage.
+        status=$?
         docker logs $container_id
+        if [ $status -gt 0 ]; then
+            exit $status
+        fi
     else
-        coverage run -m pytest -vvvv -m "not docker"  # Run the tests and check for test coverage.
+        pytest -vvvv -m "not docker"  # Run the tests and check for test coverage.
     fi
-  - coverage report -m  # Generate test coverage report.
-  - codecov  # Upload the report to codecov.
   - make -C docs html  # Build the documentation.
diff --git a/requirements-dev.txt b/requirements-dev.txt
index fe6230d6..237a2957 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,14 +1,12 @@
 # These are required for developing the package (running the tests, building
 # the documentation) but not necessarily required for _using_ it.
-codecov
-coverage
 flake8
 pytest
-sphinx
 vcrpy
 # These are dependencies of various sphinx extensions for documentation.
 ipython
 matplotlib
 numpydoc
+sphinx
 sphinx-copybutton
 sphinx_rtd_theme
diff --git a/setup.py b/setup.py
index 804a68f4..1220b885 100644
--- a/setup.py
+++ b/setup.py
@@ -48,6 +48,9 @@
         'console_scripts': [
             # 'command = some.module:some_function',
         ],
+        # entry point to avoid local.yml file
+        # https://blueskyproject.io/databroker/reference/configuration.html?highlight=entry%20point#advanced-configuration-via-python-package
+        "intake.catalogs": ["local = sirepo_bluesky:sirepo_bluesky_catalog_instance"],
     },
     include_package_data=True,
     package_data={
diff --git a/sirepo_bluesky/__init__.py b/sirepo_bluesky/__init__.py
index e44e9d15..7a0877a2 100644
--- a/sirepo_bluesky/__init__.py
+++ b/sirepo_bluesky/__init__.py
@@ -1,3 +1,12 @@
+import intake
 from ._version import get_versions
 __version__ = get_versions()['version']
 del get_versions
+
+# Look up a driver class by its name in registry.
+catalog_class = intake.registry["bluesky-mongo-normalized-catalog"]
+
+sirepo_bluesky_catalog_instance = catalog_class(
+        metadatastore_db="mongodb://localhost:27017/md",
+        asset_registry_db="mongodb://localhost:27017/ar",
+)


Test patch:
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/auth.db b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/auth.db
new file mode 100644
index 00000000..8e70d207
Binary files /dev/null and b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/auth.db differ
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/supervisor-job/.empty b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/supervisor-job/.empty
new file mode 100644
index 00000000..e69de29b
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/supervisor-srv/.empty b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/supervisor-srv/.empty
new file mode 100644
index 00000000..e69de29b
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/00000000/sirepo-data.json b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000000/sirepo-data.json
similarity index 100%
rename from sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/00000000/sirepo-data.json
rename to sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000000/sirepo-data.json
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/00000001/sirepo-data.json b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000001/sirepo-data.json
similarity index 100%
rename from sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/00000001/sirepo-data.json
rename to sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000001/sirepo-data.json
diff --git a/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/lib/_user_beam_list.json b/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/lib/_user_beam_list.json
similarity index 100%
rename from sirepo_bluesky/tests/SIREPO_SRDB_ROOT/testuser/srw/lib/_user_beam_list.json
rename to sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/lib/_user_beam_list.json
diff --git a/sirepo_bluesky/tests/test_entrypoint.py b/sirepo_bluesky/tests/test_entrypoint.py
new file mode 100644
index 00000000..a6f28c1f
--- /dev/null
+++ b/sirepo_bluesky/tests/test_entrypoint.py
@@ -0,0 +1,6 @@
+from databroker import Broker
+
+
+def test_broker():
+    db = Broker.named("local")
+    return db