Add tests for missing logs APIs

This commit is contained in:
Joseph Schorr 2017-02-08 16:52:17 -08:00
parent 6384b47849
commit 8d96d8b682
2 changed files with 27 additions and 2 deletions

View file

@ -9,7 +9,7 @@ from endpoints.api import (resource, nickname, ApiResource, query_param, parse_a
RepositoryParamResource, require_repo_admin, related_user_resource,
format_date, require_user_admin, path_param, require_scope, page_support)
from endpoints.exception import Unauthorized, NotFound
from auth.permissions import AdministerOrganizationPermission, AdministerOrganizationPermission
from auth.permissions import AdministerOrganizationPermission
from auth.auth_context import get_authenticated_user
from data import model, database
from auth import scopes

View file

@ -51,7 +51,8 @@ from endpoints.api.user import (PrivateRepositories, ConvertToOrganization, Sign
from endpoints.api.repotoken import RepositoryToken, RepositoryTokenList
from endpoints.api.prototype import PermissionPrototype, PermissionPrototypeList
from endpoints.api.logs import UserLogs, OrgLogs, OrgAggregateLogs, UserAggregateLogs
from endpoints.api.logs import (UserLogs, OrgLogs, OrgAggregateLogs, UserAggregateLogs,
RepositoryLogs, RepositoryAggregateLogs)
from endpoints.api.billing import (UserCard, UserPlan, ListPlans, OrganizationCard,
OrganizationPlan)
from endpoints.api.discovery import DiscoveryResource
@ -3551,6 +3552,30 @@ class TestOrgRobots(ApiTestCase):
class TestLogs(ApiTestCase):
def test_repo_logs(self):
self.login(ADMIN_ACCESS_USER)
json = self.getJsonResponse(RepositoryLogs, params=dict(repository='devtable/simple'))
assert 'logs' in json
assert 'start_time' in json
assert 'end_time' in json
def test_repo_logs_crossyear(self):
self.login(ADMIN_ACCESS_USER)
json = self.getJsonResponse(RepositoryLogs, params=dict(repository='devtable/simple',
starttime='12/01/2016',
endtime='1/09/2017'))
self.assertEquals('Thu, 01 Dec 2016 00:00:00 -0000', json['start_time'])
self.assertEquals('Tue, 10 Jan 2017 00:00:00 -0000', json['end_time'])
def test_repo_aggregate_logs(self):
self.login(ADMIN_ACCESS_USER)
json = self.getJsonResponse(RepositoryAggregateLogs, params=dict(repository='devtable/simple'))
assert 'aggregated' in json
assert len(json['aggregated']) > 0
def test_user_logs(self):
self.login(ADMIN_ACCESS_USER)