Skip to content

Commit

Permalink
Merge pull request #3 from coreywright/fix_tests
Browse files Browse the repository at this point in the history
Fix unit tests
  • Loading branch information
Troy Larson authored Apr 25, 2017
2 parents 02c0417 + 3f920d3 commit 06d4f3e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tests/test_progressinsight.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import arrow
from moto import mock_dynamodb2
import boto3


redis_data = """
Expand Down Expand Up @@ -89,6 +90,9 @@
"""


boto3.setup_default_session(region_name='foo')


class MockProgressManager(object):
def get_all_by_key(self, key):
return None
Expand Down Expand Up @@ -334,7 +338,7 @@ def test_no_metric_sets_has_no_metric_flag():

@patch('fluentmetrics.FluentMetric.seconds')
@patch('fluentmetrics.FluentMetric.count')
def test_success_logs_two_metrics(s_mock, c_mock):
def test_success_logs_two_metrics(c_mock, s_mock):
a = setup_basic().find_friendly_id('a').with_metric(Namespace='ns',
Metric='m')
a.start(Parents=True)
Expand All @@ -347,7 +351,7 @@ def test_success_logs_two_metrics(s_mock, c_mock):

@patch('fluentmetrics.FluentMetric.seconds')
@patch('fluentmetrics.FluentMetric.count')
def test_success_stops_timer(s_mock, c_mock):
def test_success_stops_timer(c_mock, s_mock):
a = setup_basic().find_friendly_id('a').with_metric(Namespace='ns',
Metric='m')
a.start(Parents=True)
Expand All @@ -360,7 +364,7 @@ def test_success_stops_timer(s_mock, c_mock):

@patch('fluentmetrics.FluentMetric.seconds')
@patch('fluentmetrics.FluentMetric.count')
def test_failed_logs_two_metrics(s_mock, c_mock):
def test_failed_logs_two_metrics(c_mock, s_mock):
a = setup_basic().find_friendly_id('a').with_metric(Namespace='ns',
Metric='m')
a.start(Parents=True)
Expand All @@ -373,7 +377,7 @@ def test_failed_logs_two_metrics(s_mock, c_mock):

@patch('fluentmetrics.FluentMetric.seconds')
@patch('fluentmetrics.FluentMetric.count')
def test_fail_stops_timer(s_mock, c_mock):
def test_fail_stops_timer(c_mock, s_mock):
a = setup_basic().find_friendly_id('a').with_metric(Namespace='ns',
Metric='m')
a.start(Parents=True)
Expand All @@ -386,7 +390,7 @@ def test_fail_stops_timer(s_mock, c_mock):

@patch('fluentmetrics.FluentMetric.seconds')
@patch('fluentmetrics.FluentMetric.count')
def test_canceled_logs_two_metrics(s_mock, c_mock):
def test_canceled_logs_two_metrics(c_mock, s_mock):
a = setup_basic().find_friendly_id('a').with_metric(Namespace='ns',
Metric='m')
a.start(Parents=True)
Expand Down Expand Up @@ -733,6 +737,7 @@ def test_to_update_item_done_true_sets_done_true():
assert 'IsDone=:d' in ue


@mock_dynamodb2
@patch('progressinsight.DynamoDbDriver.create_tables')
def test_dynamodb_creates_tables_if_not_exist(ct_mock):
setup_basic_d()
Expand All @@ -750,20 +755,13 @@ def test_create_tables_called_only_once(ct_mock):

@mock_dynamodb2
@patch('tests.test_progressinsight.DynamoDbDriver.update_tracker')
def test_create_tables_called_only_once(ut_mock):
def test_update_tracker_called_only_once(ut_mock):
t = setup_basic_d().start().succeed().update()
t.update()
assert ut_mock.called_once()


@mock_dynamodb2
@patch('tests.test_progressinsight.DynamoDbDriver.update_tracker')
def test_create_tables_called_only_once(ut_mock):
t = setup_basic_d().start().succeed().update()
t.update()
assert ut_mock.called_once()


@patch('progressinsight.TrackerBase.load')
def test_refresh_calls_load(load_mock):
t = setup_basic_d().start().succeed().update()
Expand Down

0 comments on commit 06d4f3e

Please sign in to comment.