Skip to content
This repository
  • 3 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
7  discogs_client/models.py
@@ -430,6 +430,7 @@ class Artist(PrimaryAPIObject):
430 430
     profile = SimpleField()
431 431
     data_quality = SimpleField()
432 432
     name_variations = SimpleField(key='namevariations')
  433
+    url = SimpleField('uri')
433 434
     urls = SimpleField()
434 435
     aliases = ListField('Artist')
435 436
     members = ListField('Artist')
@@ -458,6 +459,7 @@ class Release(PrimaryAPIObject):
458 459
     country = SimpleField()
459 460
     notes = SimpleField()
460 461
     formats = SimpleField()
  462
+    url = SimpleField('uri')
461 463
     videos = ListField('Video')
462 464
     tracklist = ListField('Track')
463 465
     artists = ListField('Artist')
@@ -488,6 +490,7 @@ class Master(PrimaryAPIObject):
488 490
     styles = SimpleField()
489 491
     genres = SimpleField()
490 492
     images = SimpleField()
  493
+    url = SimpleField('uri')
491 494
     videos = ListField('Video')
492 495
     tracklist = ListField('Track')
493 496
     main_release = ObjectField('Release', as_id=True)
@@ -509,6 +512,7 @@ class Label(PrimaryAPIObject):
509 512
     images = SimpleField()
510 513
     contact_info = SimpleField()
511 514
     data_quality = SimpleField()
  515
+    url = SimpleField('uri')
512 516
     sublabels = ListField('Label')
513 517
     parent_label = ObjectField('Label', optional=True)
514 518
     releases = ObjectCollection('Release')
@@ -530,6 +534,7 @@ class User(PrimaryAPIObject):
530 534
     num_lists = SimpleField()
531 535
     rank = SimpleField()
532 536
     rating_avg = SimpleField()
  537
+    url = SimpleField('uri')
533 538
     name = SimpleField(writable=True)
534 539
     profile = SimpleField(writable=True)
535 540
     location = SimpleField(writable=True)
@@ -611,6 +616,7 @@ class Listing(PrimaryAPIObject):
611 616
     ships_from = SimpleField()
612 617
     comments = SimpleField()
613 618
     audio = SimpleField()
  619
+    url = SimpleField('uri')
614 620
     price = ObjectField('Price')
615 621
     release = ObjectField('Release')
616 622
     seller = ObjectField('User')
@@ -629,6 +635,7 @@ class Order(PrimaryAPIObject):
629 635
     next_status = SimpleField()
630 636
     shipping_address = SimpleField()
631 637
     additional_instructions = SimpleField()
  638
+    url = SimpleField('uri')
632 639
     status = SimpleField(writable=True)
633 640
     fee = ObjectField('Price')
634 641
     buyer = ObjectField('User')
38  discogs_client/tests/test_utils.py
... ...
@@ -0,0 +1,38 @@
  1
+import unittest
  2
+from datetime import datetime
  3
+from discogs_client.tests import DiscogsClientTestCase
  4
+from discogs_client import utils
  5
+
  6
+class UtilsTestCase(DiscogsClientTestCase):
  7
+    def test_update_qs(self):
  8
+        """update_qs helper works as intended"""
  9
+        u = utils.update_qs
  10
+        self.assertEqual(u('http://example.com', {'foo': 'bar'}), 'http://example.com?foo=bar')
  11
+        self.assertEqual(u('http://example.com?foo=bar', {'foo': 'baz'}), 'http://example.com?foo=bar&foo=baz')
  12
+        self.assertEqual(u('http://example.com?c=3&a=yep', {'a': 1, 'b': '1'}), 'http://example.com?c=3&a=yep&a=1&b=1')
  13
+
  14
+    def test_omit_none(self):
  15
+        o = utils.omit_none
  16
+        self.assertEqual(o({
  17
+            'foo': None,
  18
+            'baz': 'bat',
  19
+            'qux': None,
  20
+            'flan': 0,
  21
+        }), {
  22
+            'baz': 'bat',
  23
+            'flan': 0,
  24
+        })
  25
+
  26
+        self.assertEqual(o(dict((k, None) for k in ('qux', 'quux', 'quuux'))), {})
  27
+        self.assertEqual(o({'nope': 'yep'}), {'nope': 'yep'})
  28
+        self.assertEqual(o({}), {})
  29
+
  30
+    def test_parse_timestamp(self):
  31
+        p = utils.parse_timestamp
  32
+        self.assertEqual(p('2012-01-01T00:00:00'), datetime(2012, 1, 1, 0, 0, 0))
  33
+        self.assertEqual(p('2001-05-25T00:00:42'), datetime(2001, 5, 25, 0, 0, 42))
  34
+
  35
+def suite():
  36
+    suite = unittest.TestSuite()
  37
+    suite = unittest.TestLoader().loadTestsFromTestCase(UtilsTestCase)
  38
+    return suite
1  discogs_client/utils.py
@@ -14,4 +14,5 @@ def update_qs(url, params):
14 14
 
15 15
 
16 16
 def omit_none(dict_):
  17
+    """Removes any key from a dict that has a value of None."""
17 18
     return dict((k, v) for k, v in dict_.iteritems() if v is not None)

No commit comments for this range

Something went wrong with that request. Please try again.