<s> from __future__ import absolute_import <EOL> from django . core . urlresolvers import reverse <EOL> from sentry . models import TagKey , TagValue <EOL> from sentry . testutils import APITestCase <EOL> class ProjectTagKeyValuesTest ( APITestCase ) : <EOL> def test_simple ( self ) : <EOL> project = self . create_project ( ) <EOL> tagkey = TagKey . objects . create ( project = project , key = '<STR_LIT:foo>' ) <EOL> TagValue . objects . create ( project = project , key = '<STR_LIT:foo>' , value = '<STR_LIT:bar>' ) <EOL> self . login_as ( user = self . user ) <EOL> url = reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : project . organization . slug , <EOL> '<STR_LIT>' : project . slug , <EOL> '<STR_LIT:key>' : tagkey . key , <EOL> } ) <EOL> response = self . client . get ( url ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:value>' ] == '<STR_LIT:bar>' <EOL> def test_query ( self ) : <EOL> project = self . create_project ( ) <EOL> tagkey = TagKey . objects . create ( project = project , key = '<STR_LIT:foo>' ) <EOL> TagValue . objects . create ( project = project , key = '<STR_LIT:foo>' , value = '<STR_LIT:bar>' ) <EOL> self . login_as ( user = self . user ) <EOL> url = reverse ( '<STR_LIT>' , kwargs = { <EOL> '<STR_LIT>' : project . organization . slug , <EOL> '<STR_LIT>' : project . slug , <EOL> '<STR_LIT:key>' : tagkey . key , <EOL> } ) <EOL> response = self . client . get ( url + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:value>' ] == '<STR_LIT:bar>' <EOL> response = self . client . get ( url + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:0> </s>
