Skip to content

Commit

Permalink
change to mock test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiachen Liu committed Feb 16, 2021
1 parent 912748e commit 39cf90d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tests/unit/harvesters/moa/test_moa_source.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Test MOAlmanac source"""
import pytest
from metakb import PROJECT_ROOT
from metakb.harvesters.moalmanac import MOAlmanac
from mock import patch
import json


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -32,13 +35,19 @@ def source66():
}


def test_source66(sources, source66):
@patch.object(MOAlmanac, '_get_all_sources')
def test_source66(test_get_all_sources, source66):
"""Test moa harvester works correctly for evidence."""
for e in sources:
if e['id'] == 66:
actual = e
with open(f"{PROJECT_ROOT}/tests/data/"
f"harvesters/moa/sources.json") as f:
data = json.load(f)
test_get_all_sources.return_value = data

sources = MOAlmanac()._harvest_sources()

actual = None
for s in sources:
if s['id'] == 66:
actual = s
break
assert actual.keys() == source66.keys()
keys = source66.keys()
for key in keys:
assert actual[key] == source66[key]
assert actual == source66

0 comments on commit 39cf90d

Please sign in to comment.