# Path: blindr/models/event.py
# _ADJUSTED_DELAY = 5
# class Event(object):
#     def create(data):
#     def fetch(user=None, city=None, since=60):
#     def fetch_history(user, other,since=0):


import tests.utils.fake_dynamodb
import unittest
import time
import boto
from unittest.mock import MagicMock
from freezegun import freeze_time
from blindr.models.event import Event, events
        self.assertEqual('city:some_user', user)

    def test_fetch_float_sent_at(self):
        events.query_2 = MagicMock(return_value = [{'sent_at':'1.23'}])
        event = Event.fetch()[0]

        self.assertIs(type(event['sent_at']), float)

    def test_fetch_history_sort_participants_id(self):
        events.query_2 = MagicMock(return_value = [])

        Event.fetch_history('123','456')
        participants = events.query_2.call_args[1]['participants__eq']
        self.assertEqual('123:456', participants)

        Event.fetch_history('321','123')
        participants = events.query_2.call_args[1]['participants__eq']
        self.assertEqual('123:321', participants)

    def test_fetch_history_since(self):
        events.query_2 = MagicMock(return_value = [])

        Event.fetch_history('123','456', since=12300)
        events.query_2.assert_called_with(
                participants__eq='123:456',
                sent_at__gte=12300,
                index='participants-index')

    def test_fetch_history_float_sent_at(self):
        events.query_2 = MagicMock(return_value = [{'sent_at':'1.23'}])

# Path: blindr/models/event.py
# _ADJUSTED_DELAY = 5
# class Event(object):
#     def create(data):
#     def fetch(user=None, city=None, since=60):
#     def fetch_history(user, other,since=0):


# Path: tests/models/test_event.py
import tests.utils.fake_dynamodb
import unittest
import time
import boto
from unittest.mock import MagicMock
from freezegun import freeze_time
from blindr.models.event import Event, events

        self.assertEqual('city:some_user', user)

    def test_fetch_float_sent_at(self):
        events.query_2 = MagicMock(return_value = [{'sent_at':'1.23'}])
        event = Event.fetch()[0]

        self.assertIs(type(event['sent_at']), float)

    def test_fetch_history_sort_participants_id(self):
        events.query_2 = MagicMock(return_value = [])

        Event.fetch_history('123','456')
        participants = events.query_2.call_args[1]['participants__eq']
        self.assertEqual('123:456', participants)

        Event.fetch_history('321','123')
        participants = events.query_2.call_args[1]['participants__eq']
        self.assertEqual('123:321', participants)

    def test_fetch_history_since(self):
        events.query_2 = MagicMock(return_value = [])

        Event.fetch_history('123','456', since=12300)
        events.query_2.assert_called_with(
                participants__eq='123:456',
                sent_at__gte=12300,
                index='participants-index')

    def test_fetch_history_float_sent_at(self):
        events.query_2 = MagicMock(return_value = [{'sent_at':'1.23'}])

        event = Event.fetch_history('123','321')[0]