import pytest

import mapbox
from mapbox import errors

def test_resource_type_invalid():
    """'random' is not a valid resource type."""
    with pytest.raises(errors.InvalidResourceTypeError):
        mapbox.Analytics(access_token='pk.test')._validate_resource_type('random')

@pytest.mark.parametrize('resource_type', ['tokens', 'styles', 'accounts', 'tilesets'])
def test_profile_valid(resource_type):
    """Resource types are valid."""
    assert resource_type == mapbox.Analytics(
        access_token='pk.test')._validate_resource_type(resource_type)

def test_period_invalid():
	"""Providing only one timestamp is invalid."""
	with pytest.raises(errors.InvalidPeriodError):
		mapbox.Analytics(access_token='pk.test')._validate_period('2016-03-22T00:00:00.000Z', None)

def test_period_valid():
	"""Providing two valid timestamps."""
	start = '2016-03-22T00:00:00.000Z'
	end = '2016-03-24T00:00:00.000Z'
	period = start, end
	assert period == mapbox.Analytics(access_token='pk.test')._validate_period(start, end)

def test_username_invalid():
	"""Username is requird."""
	with pytest.raises(errors.InvalidUsernameError):
		mapbox.Analytics(access_token='pk.test')._validate_username(None)

def test_username_valid():
	"""Providing valid username"""
	user = 'abc'
	assert user == mapbox.Analytics(access_token='pk.test')._validate_username(user)

@@ -586,54 +586,314 @@
 ):%0A%09
-%22%22%22Providing only one timestamp is invalid.%22%22%22
+with pytest.raises(errors.InvalidPeriodError):%0A%09%09mapbox.Analytics(access_token='pk.test')._validate_period('2016-03-22T00:00:00.000Z', None)%0A%0A%09with pytest.raises(errors.InvalidPeriodError):%0A%09%09mapbox.Analytics(access_token='pk.test')._validate_period('2016-03-22T00:00:00.000Z', '2016-03-20T00:00:00.000Z')%0A
 %0A%09wi
@@ -1025,20 +1025,42 @@
 .000Z', 
-None
+'2017-04-20T00:00:00.000Z'
 )%0A%0Adef t
@@ -1083,47 +1083,8 @@
 ():%0A
-%09%22%22%22Providing two valid timestamps.%22%22%22%0A
 %09sta
@@ -1259,16 +1259,152 @@
 , end)%0A%0A
+%09start = None%0A%09end = None%0A%09period = start, end%0A%09assert period == mapbox.Analytics(access_token='pk.test')._validate_period(start, end)%0A%0A
 def test

test coverage