-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathtest_key.py
More file actions
27 lines (20 loc) · 779 Bytes
/
test_key.py
File metadata and controls
27 lines (20 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import unittest2
from dataset import Dataset
from key import Key
class TestKey(unittest2.TestCase):
def test_init_no_arguments(self):
key = Key()
self.assertEqual([{'kind': ''}], key.path())
self.assertEqual('', key.kind())
self.assertEqual(None, key.dataset())
self.assertEqual(None, key.namespace())
def test_dataset_prefix(self):
key = Key(dataset=Dataset('dset'))
protokey = key.to_protobuf()
self.assertEqual('s~dset', protokey.partition_id.dataset_id)
key = Key(dataset=Dataset('s~dset'))
protokey = key.to_protobuf()
self.assertEqual('s~dset', protokey.partition_id.dataset_id)
key = Key(dataset=Dataset('e~dset'))
protokey = key.to_protobuf()
self.assertEqual('e~dset', protokey.partition_id.dataset_id)